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" Dialog Box For Parts & Assemblies

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

Show "Properties" Dialog Box For Parts & Assemblies

Can anybody help?

 

I have the following Fusion 360 "Python" script file....


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

sels = ui.activeSelections

sels.add(root.bRepBodies[0])

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

 

It works great when I run the script on a "Part" document but not on a "Assembly" document.

 

Can anybody update the script for me so that it works on both "Part" & "Assembly" documents?

 

Many thanks in advance!

 

Darren

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

@isocam you need to use the component instance under which the body is present. Attached is the modified code. I have assumed the body is present under the first instance of the component. One needs to make sure that the component and body exist before accessing them.

 

#Author-
#Description-

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
        sels = ui.activeSelections
        
        # here use the component instance under which the body is present
        #  for which the properties dialog needs to display.
        sels.add(root.allOccurrences[0].bRepBodies[0])

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

  

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

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