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: 

I want to use TemporaryBRepManager.createBox in Parametric mode

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
kandennti
291 Views, 2 Replies

I want to use TemporaryBRepManager.createBox in Parametric mode

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.

2 REPLIES 2
Message 2 of 3
goyals
in reply to: kandennti

@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
Message 3 of 3
kandennti
in reply to: goyals

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.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report