Display "PROPERTIES" box using a Fusion 360 Python command

Display "PROPERTIES" box using a Fusion 360 Python command

isocam
Collaborator Collaborator
510 Views
2 Replies
Message 1 of 3

Display "PROPERTIES" box using a Fusion 360 Python command

isocam
Collaborator
Collaborator

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

0 Likes
511 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor

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()))
0 Likes
Message 3 of 3

BrianEkins
Mentor
Mentor

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