Fusion - Set & Get Component Attribute
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Can anybody help?
Can anybody tell me if the following Python code is correct to "Get" & "Set" a part attribute?
def SetProperty(PropertyName, PropertyValue):
app = adsk.core.Application.get()
selectedComponent = adsk.fusion.Design.cast(app.activeProduct).rootComponent
compAttributes = selectedComponent.attributes
newAttribute = compAttributes.add('PartAttributes', PropertyName, PropertyValue)
# -----------------------------------------------------------------------------------
def GetProperty(PropertyName):
app = adsk.core.Application.get()
selectedComponent = adsk.fusion.Design.cast(app.activeProduct).rootComponent
compAttributes = selectedComponent.attributes
readAttribute = compAttributes.itemByName('PartAttributes', PropertyName)
PropertyValue = readAttribute.value
return PropertyValue
Many thanks in advance!
Darren