Add OrientedBoundingBox3D to Model

Add OrientedBoundingBox3D to Model

ebunn3
Advocate Advocate
549 Views
2 Replies
Message 1 of 3

Add OrientedBoundingBox3D to Model

ebunn3
Advocate
Advocate

How would one go about adding a OrientedBoundingBox3D created with 

adsk.core.OrientedBoundingBox3D.create() to the model as a body?  I'm sure it is something simple but it escapes me.  Thanks in advance.

 

Eric

0 Likes
Accepted solutions (1)
550 Views
2 Replies
Replies (2)
Message 2 of 3

tykapl.breuil
Advocate
Advocate

I don't think you can add a bounding box to a model as a bounding box is automatically calculated given a model's geometry.

 

However if what you want is to calculate a model's orientedboundingbox then you can use this method : https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-4b13c86c-7aa0-4555-b3e3-02f7d1b01d10

I'm not sure if the OrientedBoundingBox object you create through the .create() method has any other use than using it with the .contains method.

0 Likes
Message 3 of 3

BrianEkins
Mentor
Mentor
Accepted solution

You can create a BRepBody object using an OrientedBoundBox3D object.  This is done using the createBox method on the TemporaryBRepManager object.  The body returned exists only in memory.  To create a solid in the current design you can use the BRepBodies.add method.  The result is a non-parametric body.  If your design is not set to capture the design history you can use the BRepBodies.add method and pass in the body.  However, if your design is a parametric design you have to first create a base feature and then you can create the body within it.  All non-parametric data has to exist with a base feature, if the design is parametric.  This is demonstrated in the code below.

 

def run(context):  
    app = adsk.core.Application.get()
    ui  = app.userInterface
    des: adsk.fusion.Design = app.activeProduct
    root = des.rootComponent

    # Get TemporaryBRepManager
    tempBrepMgr = adsk.fusion.TemporaryBRepManager.get()

    centerPoint = adsk.core.Point3D.create(0.0, 10.0, 0.0)
    lengthDir = adsk.core.Vector3D.create(1.0, 1.0, 0.0)
    widthDir = adsk.core.Vector3D.create(-1.0, 1.0, 0.0)
    orientedBoundingBox3D = adsk.core.OrientedBoundingBox3D.create(centerPoint, 
                                                                   lengthDir,
                                                                   widthDir,
                                                                   5.0,
                                                                   6.0,
                                                                   2.0
                                                                   )
    # Create temporary B-Rep box body.                                                              
    boxBody = tempBrepMgr.createBox(orientedBoundingBox3D)

    # Create a base feature to create the real box in.
    baseFeature = root.features.baseFeatures.add()
    baseFeature.startEdit()
    root.bRepBodies.add(boxBody, baseFeature)
    baseFeature.finishEdit()

cr 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com