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: 

Display "PROPERTIES" box using a Fusion 360 Python command

2 REPLIES 2
Reply
Message 1 of 3
isocam
256 Views, 2 Replies

Display "PROPERTIES" box using a Fusion 360 Python command

Can anybody help?

 

Is it possible to display the "PROPERTIES" box using a Fusion 360 Python command?

 

Please see the attached picture.

 

Many thanks in advance!!!

 

Darren

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

Hi @isocam .

 

Try this.

# Fusion360API Python script
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()))
Message 3 of 3
BrianEkins
in reply to: isocam

Unfortunately, I don't see a good solution for this.  Typically, when you just need to start a command you can execute it directly.  This is what's demonstrated in the previous post.  The recommended way to execute a command through the API is to get the command definition, using the ID of the command and then execute it.

 

cmdDef = ui.commandDefinitions.itemById('FusionPropertiesCommand')
cmdDef.execute()

 

This will work for any command but what you're doing is the equivalent of clicking the button in the user interface to start the command and you can't do anything to control the command after that.  Some commands are context-sensitive, so when they're executed they'll work with whatever is currently active or selected.  In those cases, you need to make sure the context is correct before executing the command.

The Properties command shows the properties for the component you select in the browser when you run the command.  I wasn't able to find a way to set the context so the Properties command would display for a particular component.  In fact, when I directly run the Properties command, the dialog is displayed with no data.  Probably because it doesn't know which component to display information for.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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