I want to use TemporaryBRepManager.createBox in Parametric mode

kandennti
Mentor
Mentor

I want to use TemporaryBRepManager.createBox in Parametric mode

kandennti
Mentor
Mentor

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.

0 Likes
Reply
Accepted solutions (1)
473 Views
2 Replies
Replies (2)

goyals
Autodesk
Autodesk
Accepted solution

@kandennti Sharing an article on Temporary BRep manager by Brian Ekins

 

https://ekinssolutions.com/using-temporary-b-rep-in-fusion-360/



Shyam Goyal
Sr. Software Dev. Manager
1 Like

kandennti
Mentor
Mentor

Thank you @goyals .
The second parameter was missing.

 

・・・
        brepBox = tmpMgr.createBox(box)

        # baseFeature.bodies.add(brepBox)
        root.bRepBodies.add(brepBox, baseFeature)
        
        baseFeature.finishEdit()
・・・
1 Like