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: 

Show Properties Box

1 REPLY 1
Reply
Message 1 of 2
isocam
87 Views, 1 Reply

Show Properties Box

Can anybody help?

 

I have the following Python script that works great if the Fusion 360 document is a single part (not an assembly).

 

import adsk.core, adsk.fusion, traceback

def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
des = app.activeProduct
root = des.rootComponent

# select brepbody
sels = ui.activeSelections
sels.add(root.bRepBodies[0])

# show props - textcommands
app.executeTextCommand(u'Commands.Start FusionPropertiesCommand')
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Does anybody know how to modify the above so that it works on both a single part and an assembly?

 

Many thanks in advance!

 

Darren

1 REPLY 1
Message 2 of 2
Rushikesh.kadam
in reply to: isocam

@isocam you need to get the body from the component when using an assembly. Here is the modified code of your version to select all the bodies present under root and individual components. 

 

import traceback, adsk.fusion, adsk.core
def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        des = app.activeProduct
        root = des.rootComponent

        # select brepbody
        sels = ui.activeSelections
        for body in root.bRepBodies:
            sels.add(body)
        for component in root.allOccurrences:
            for body in component.bRepBodies:
                sels.add(body)
        

        # show props - textcommands
        app.executeTextCommand(u'Commands.Start FusionPropertiesCommand')
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

If you want to just select the first body in the first component of the assembly you can simply use 

sels.add(root.allOccurrences[0].bRepBodies[0])

------------------------------------------------------------------------------------------------------------------------------

If my reply was helpful, please click the "Accept as Solution" button. It helps others get the answer quickly! A "Like" is always welcomed.




Rushikesh Kadam
Senior QA Engineer
Quality Assurance
Autodesk, Inc.


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