Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add OrientedBoundingBox3D to Model

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ebunn3
211 Views, 2 Replies

Add OrientedBoundingBox3D to Model

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

2 REPLIES 2
Message 2 of 3
tykapl.breuil
in reply to: ebunn3

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.

Message 3 of 3
BrianEkins
in reply to: ebunn3

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report