Fusion - Set & Get Component Attribute

Fusion - Set & Get Component Attribute

isocam
Collaborator Collaborator
131 Views
0 Replies
Message 1 of 1

Fusion - Set & Get Component Attribute

isocam
Collaborator
Collaborator

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

0 Likes
132 Views
0 Replies
Replies (0)