Python Code - Get Parts Parameters Whilst Traversing An Assembly

Python Code - Get Parts Parameters Whilst Traversing An Assembly

isocam
Collaborator Collaborator
81 Views
0 Replies
Message 1 of 1

Python Code - Get Parts Parameters Whilst Traversing An Assembly

isocam
Collaborator
Collaborator

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

0 Likes
82 Views
0 Replies
Replies (0)