Get Part Attributes When Exporting A BOM Using A Python Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anybody help?
I can set a Fusion 360 "part attribute" using the following Python script....
def SetPartType(PartType):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
selectedComponent = adsk.fusion.Design.cast(app.activeProduct).rootComponent
compAttributes = selectedComponent.attributes
newAttribute = compAttributes.add('PartAttributes', 'Part: Type', PartType)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
And then, I can read the "part attribute" using the following Python script....
def GetPartType():
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
selectedComponent = adsk.fusion.Design.cast(app.activeProduct).rootComponent
compAttributes = selectedComponent.attributes
readAttribute = compAttributes.itemByName('PartAttributes', 'Part: Type')
PartType = readAttribute.value
return PartType
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
How can I get the part attribute when exporting a BOM file using a Python Script?
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]
PartType = ???????
Many thanks in advance!
Darren