Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there any way to retrieve the resourceFolder for a Feature object? (Like one can do for CommandDefinition)
Solved! Go to Solution.
Is there any way to retrieve the resourceFolder for a Feature object? (Like one can do for CommandDefinition)
Solved! Go to Solution.
Hi @thomasa88 .
#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()))