Menu

boolean with Objects

Scripting
Snow
2013-04-27
2019-10-26
  • Snow

    Snow - 2013-04-27

    Hi,

    is there an example/possibility/simple approach to do a boolean operation on two objects. e.g cut a cube from a sphere ?

    Thanks,
    S

     
  • Luke S

    Luke S - 2013-04-27

    Hi. AOI has a built in boolean engine. If you are new to AOI, and are trying to figure out what it can do, I'd recommend getting the manual. Lot of cool stuff there.

     
  • Peter Eastman

    Peter Eastman - 2013-04-27

    And the short answer to your question: select the cube and the sphere, then choose Tools->Boolean Modelling.

    Peter

     
  • Snow

    Snow - 2013-04-29

    Hi

    and thanks for your answers but as this is the scripting section I hoped more for something like  (in that case with cylinders)

    bearing01outer = new Cylinder(1.0, 2.2, 2.2, 1.0);
    bearing01inner = new Cylinder(3.0, 0.8, 0.8, 1.0);
    bearing01 = new CSGObject(bearing01out, bearing01inner, CSGObject.DIFFERENCE21);

    To get a new Object through a boolean transformation like in the menu. I struggle with the Object Info as it looks like a certain info is needed but what would be here the right one/code ?

    V

     
  • Peter Eastman

    Peter Eastman - 2013-04-30

    What you have is very close to correct.  What's missing is information about position.  You've said what two objects you want to create the boolean from, but how are they positioned relative to each other?  That will make a big difference in the result.  So you need to provide a CoordinateSystem for each one that gives its position and orientation relative to the parent object.  Then you can say

    info1 = new ObjectInfo(bearing01outer, outerCoords, "outer");
    info2 = new ObjectInfo(bearing01inner, innerCoords, "inner");
    bearing01 = new CSGObject(info1, info2, CSGObject.DIFFERENCE21);
    

    Peter

     
  • Snow

    Snow - 2013-04-30

    now that did work / do what I tried to achieve

    bearing01outer = new Cylinder(1.0, 2.2, 2.2, 1.0);
    bearing01inner = new Cylinder(1.1, 0.8, 0.8, 1.0);
    pos03 = new Vec3(0.0, 0.0, 0.0);
    info1 = new ObjectInfo(bearing01outer, new CoordinateSystem(pos03, 0, 0, 0), "outer");
    info2 = new ObjectInfo(bearing01inner, new CoordinateSystem(pos03, 0, 0, 0), "inner");
    bearing01 = new CSGObject(info1, info2, CSGObject.DIFFERENCE12);
    pos04 = new Vec3(0.0, 0.0, -5.0);
    script.addObject(bearing01, new CoordinateSystem(pos04, 0, 0, 0));

    many thanks

    V

     
  • Snow

    Snow - 2013-04-30

    sorry have to ask again

    last line fails to show an CSGObject wich has been created with an Object and CSGObject as a source.
    Also I loose the textures during the Operation

    //color
    texture = new Texture ;
    texture = new UniformTexture();
    texture = new UniformTexture();
    texture = new UniformTexture();
    texture.diffuseColor.setRGB(0.0, 0.0, 1.0); //blue
    texture.diffuseColor.setRGB(0.0, 1.0, 1.0);
    texture.diffuseColor.setRGB(0.0, 0.0, 0.0);

    //-mount bloack with bearing

    //mount block
    mountBlock01basis = new Cube(3.00, 1.00, 3.00);
    mountBlock01basis.setTexture(texture, texture.getDefaultMapping(mountBlock01basis));
    pos01 = new Vec3(0.0, 0.0, 0.0);
    info1 = new ObjectInfo(mountBlock01basis, new CoordinateSystem(pos01, 0, 0, 0), "blockBasis");

    //bearing 698z (22x8x7)
    //remember x and y are radien not diameter
    bearing01outer = new Cylinder(0.7, 1.1, 1.1, 1.0);
    pos02 = new Vec3(0.0, 0.3, 0.0);
    info2 = new ObjectInfo(bearing01outer, new CoordinateSystem(pos02, 0, 0, 0), "outerBearing");

    //mountblock with bearing
    mountBlock01 = new CSGObject(info1, info2, CSGObject.UNION);
    pos03 = new Vec3(0.0, 0.0, -5.0);
    info3 = new ObjectInfo(mountBlock01, new CoordinateSystem(pos03, 0, 0, 0), "blockWithBearing");

    //mountblock with bearing and inner hole
    bearing01inner = new Cylinder(1.0, 0.4, 0.4, 1.0);
    info4 = new ObjectInfo(bearing01inner, new CoordinateSystem(pos03, 0, 0, 0), "blockWithBearingandHole");
    mountBlock = new CSGObject(info4, info3, CSGObject.DIFFERENCE21);
    pos04 = new Vec3(0.0, 3.0, 0.0);

    //--End CSG mountblock with bearing

    script.addObject(mountBlock01basis, new CoordinateSystem(pos01, 0, 0, 0));
    script.addObject(bearing01outer, new CoordinateSystem(pos02, 0, 0, 0));
    script.addObject(bearing01inner, new CoordinateSystem(pos02, 0, 0, 0));
    script.addObject(mountBlock01, new CoordinateSystem(pos03, 0, 0, 0));
    script.addObject(mountBlock, new CoordinateSystem(pos04, 0, 0, 0));

    what is wrong with the last CSGObject creation ?
    how could I keep the texture Information ?

    BTW fails dramtically in latest Dev Version as groovy script

    Thanks
    V

     
  • Peter Eastman

    Peter Eastman - 2013-05-04

    Boolean objects tend to get confused when you have two surfaces that are exactly flush with each other.  It's best to make one object extend slightly outside the other.  In your case, this happens when constructing the last boolean.  Change the height of bearing01inner from 1.0 to 2.0, and then it works fine.

    A boolean object doesn't preserve the textures of the objects it's made from.  It just treats them as shapes, then creates a completely new shape, to which you can apply a new texture.

    Peter

     
  • Snow

    Snow - 2013-05-05

    Hi Peter

    thanks, that did work . Unfortunatetly I would like to construct  more technical stuff as with the bearing and therefore must be dimensionally stable.

    If textures gets lost and boolean functions get confused, Is there any grouping functionality ?
    Are you aware of openscad.org and can you kindly comment if AOI is(will be) an aquivalent ?

    Just asking before really investing longer hours of scripting

    Many thanks
    V

     
  • Peter Eastman

    Peter Eastman - 2013-05-14

    I'm not familiar with openscad, so I don't know how the functionality compares.  Depending on what you're trying to accomplish that might be a better tool.  You could then export the objects and import them into AoI for texturing and rendering, if that's important.

    What did you have in mind by "grouping functionality"?  There are various ways of combining objects, parenting objects, etc.  What is the specific task you want to accomplish?

    Peter

     
  • Snow

    Snow - 2013-05-15

    I would like to construct some mechanical type of thing, with some parts as combination. E.g a Servo or Bearing with Holder.

    so when I loose texturing through boolean maybe I could get the same for objects with different textures as a group.  So that I could do a rotation to the group of objects where all are rotated around the same axis ?

    You mentioned
    "There are various ways of combining objects, parenting objects, etc.'
    are there simple Hello World like examples for each ?

     
  • Peter Eastman

    Peter Eastman - 2013-05-17

    Make all the objects children of one object (either one of the group of objects, or use a null object as the parent).  Do this by just dragging them in the object list.

    Select the child objects and select Animation->Keyframe Modified Tracks.  That will set a keyframe on the position and rotation tracks fixing their positions and rotations relative to their parent.

    Now move the parent object, and the children will move with it.

    Peter

     
  • Snow

    Snow - 2014-06-23

    Sorry time flew by and I didn't have a chance to try that. How to actually create child objects ?

    the problem was too get a milling like operation to a cylinder with some other objects...maybe since aoi 3.0 there is another approach ?

    S

     
    • jb hearle

      jb hearle - 2019-10-26

      "How to actually create child objects". Not sure if you mean in script or not, but just as Peter instructed, you select the objects in the right side object list menu, then just drag them sort of under another unselected object in the list, it will usually have a kind of underline looking thing on the parent object, and you can expand the parent object to pull children out again.

       

Log in to post a comment.