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 EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com