Python Code - Get Parts Parameters Whilst Traversing An Assembly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anybody help?
I am traversing an assembly using the following python code....
def traverseAssembly(occurrences, currentLevel, OutputString):
app = adsk.core.Application.get()
ui = app.userInterface
for i in range(0, occurrences.count):
occ: adsk.fusion.Occurrence = occurrences.item(i)
PartNumber = re.split(' v\d+', occ.name)[0]
PartDescription = occ.component.description
OutputString+=PartNumber + " " + PartDescription
return OutputString
Is it possible to get an individual parts parameters (if it has any) whilst traversing the assembly?
For reference, here is the python code I use to get a specific parameter.....
def GetModelParameter(ParameterName):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
design = adsk.fusion.Design.cast(app.activeProduct)
ModelParameter = design.userParameters.itemByName(ParameterName)
ParameterValue = ModelParameter.expression
return ParameterValue
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Many thanks in advance!
Darren