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: 

Get Feature resourceFolder

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
thomasa88
240 Views, 2 Replies

Get Feature resourceFolder

Is there any way to retrieve the resourceFolder for a Feature object? (Like one can do for CommandDefinition)

Labels (1)
2 REPLIES 2
Message 2 of 3
kandennti
in reply to: thomasa88

Hi @thomasa88 .

 

It seems that CommandDefinition cann't be obtained from Feature name.
key : Object type name
value : Command ID
Why not create the above dictionary and get the resourceFolder in advance?
 
I made a sample to scan the feature of the timeline.
I have only checked four, but there are not many types of Features, so it should not be impossible to check all.
#Fusion360API Python script

import adsk.core, adsk.fusion, traceback

_app = adsk.core.Application.cast(None)
_ui = adsk.core.UserInterface.cast(None)

# Object type name and command ID mapping
# key-ObjectTypeName value-commandID
_featureMap = {
    'ExtrudeFeature':'Extrude',
    'RevolveFeature':'FusionRevolveEditCommand',
    'SweepFeature':'FusionSweepEditCommand',
    'LoftFeature':'FusionRevolveEditCommand'
    }

def run(context):
    try:
        global _app, _ui
        _app = adsk.core.Application.get()
        _ui = _app.userInterface
        des :adsk.fusion.Design = _app.activeProduct

        oKCancelButtonType = adsk.core.MessageBoxButtonTypes.OKCancelButtonType
        noIconIconType = adsk.core.MessageBoxIconTypes.NoIconIconType
        dialogCancel = adsk.core.DialogResults.DialogCancel

        cmdDefs = _ui.commandDefinitions
        global _featureMap
        for tl in des.timeline:
            entType :str = tl.entity.objectType.split('::')[-1]

            if entType in _featureMap:
                cmdDef = cmdDefs.itemById(_featureMap[entType])
                if not cmdDef:
                    continue

                msg = 'ObjectType : {}\nResourceFolder : {}'.format(
                    entType, cmdDef.resourceFolder)

                print(msg)
                res =_ui.messageBox(msg, "", oKCancelButtonType, noIconIconType)
                if res == dialogCancel:
                    break
    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

1.png

Message 3 of 3
thomasa88
in reply to: kandennti

Thanks, that's the way I'm ending up doing this.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report