Hello.
I want to create a box using TemporaryBRepManager in the baseFeature of Parametric mode, but I get an error at the time of bodies.add.
#Fusion360API Python script
import adsk.core, adsk.fusion, traceback
_app = None
_ui = None
def run(context):
try:
global _app, _ui
_app = adsk.core.Application.get()
_ui = _app.userInterface
_app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
des :adsk.fusion.Design = _app.activeProduct
des.designType = adsk.fusion.DesignTypes.ParametricDesignType
# des.designType = adsk.fusion.DesignTypes.DirectDesignType
root :adsk.fusion.Component = des.rootComponent
baseFeatures = root.features.baseFeatures
baseFeature = baseFeatures.add()
baseFeature.startEdit()
tmpMgr = adsk.fusion.TemporaryBRepManager.get()
box3D = adsk.core.OrientedBoundingBox3D
pnt3D = adsk.core.Point3D
vec3D = adsk.core.Vector3D
box = box3D.create(
pnt3D.create(1.0, 2.0, 3.0),
vec3D.create(1.0, 0.0, 0.0),
vec3D.create(0.0, 1.0, 0.0),
3.0, 4.0, 5.0
)
brepBox = tmpMgr.createBox(box)
baseFeature.bodies.add(brepBox)
# root.bRepBodies.add(brepBox)
baseFeature.finishEdit()
_ui.messageBox('Done')
except:
if _ui:
_ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
In Direct mode, processing can be performed without errors.Is there a way to process in parametric mode?
Thanks in advance.
Solved! Go to Solution.
Solved by goyals. Go to Solution.
@kandennti Sharing an article on Temporary BRep manager by Brian Ekins
https://ekinssolutions.com/using-temporary-b-rep-in-fusion-360/
Thank you @goyals .
The second parameter was missing.
・・・
brepBox = tmpMgr.createBox(box)
# baseFeature.bodies.add(brepBox)
root.bRepBodies.add(brepBox, baseFeature)
baseFeature.finishEdit()
・・・
Can't find what you're looking for? Ask the community or share your knowledge.