Show "Properties" & "Edit Feature" Dialog Boxes Using Python

Show "Properties" & "Edit Feature" Dialog Boxes Using Python

isocam
Collaborator Collaborator
326 Views
1 Reply
Message 1 of 2

Show "Properties" & "Edit Feature" Dialog Boxes Using Python

isocam
Collaborator
Collaborator

Can anybody help?

 

Is it possible, using a Python script, to show the "Properties" & "Edit Feature" dialog boxes?

 

Many thanks in advance!

 

Darren

0 Likes
Accepted solutions (1)
327 Views
1 Reply
Reply (1)
Message 2 of 2

kandennti
Mentor
Mentor
Accepted solution

Hi @isocam .

 

This will bring up the RootComponent properties dialog.

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


        sels: adsk.core.Selections =  ui.activeSelections
        sels.clear()
        sels.add(root)
        app.executeTextCommand(u'Commands.Start FusionPropertiesCommand')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

However, it is not stable when tried here.

 

 

We will also show the edit dialog for the first extrusion of the RootComponent.

import adsk.core, adsk.fusion, traceback

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

        for feat in root.features:
            feat.objectType

        extrudeFeat = getExtrudeFeature(root)
        if not extrudeFeat:
            return

        sels: adsk.core.Selections =  ui.activeSelections
        sels.clear()
        sels.add(extrudeFeat)
        app.executeTextCommand(u'Commands.Start FusionExtrudeEditCommand')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

def getExtrudeFeature(comp) -> adsk.fusion.ExtrudeFeature:
    extrudeFeat = None
    for feat in comp.features:
        if feat.objectType == 'adsk::fusion::ExtrudeFeature':
            extrudeFeat = feat
            break
    
    return extrudeFeat