Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Switching Component Sheet Metal Rule

Message 1 of 3
119 Views, 2 Replies

Switching Component Sheet Metal Rule

Hey guys,


I'm trying to switch sheet metal rules for some sheet metal components within a design. This is my code:


def change_component_sheet_metal_rule(design, component, rule,ui):
        sheetMetalRule = component.activeSheetMetalRule
        sheetMetalRules = design.librarySheetMetalRules
        oldRule = sheetMetalRule
        setRule = sheetMetalRules.itemByName(rule)
        if setRule:
            sheetMetalRule = setRule


I grab the component using:

body_component = root_comp.allOccurrences.itemByName("Body:1").component
sheetMetalRule = str( + ' ' +
change_component_sheet_metal_rule(design, body_component, sheetMetalRule,ui)


Using the message boxes to debug, I can see that the component is found, the sheet metal rule is said to have changed from the old rule to the new rule found in the library. When I go into the application after running the code, all other changes from the script are applied, but the sheet metal rule hasn't changed.


I'm wondering if I'm doing something wrong, or if there is a workaround to this? If I change the sheet metal rule within the design editor everything works as it should.

Message 2 of 3
in reply to: yago6H8QN

I believe the issue is on line 7 in the first code snippet - try using this instead:


component.activeSheetMetalRule = setRule


This will trigger the 'set' function on component's activeSheetMetalRule property. The script previously was assigning the object setRule to the variable sheetMetalRule in Python code - meaning nothing really was happening 'behind the scenes'

Message 3 of 3
in reply to: yago6H8QN

Such a silly mistake! Thank you, this was the issue.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th

Autodesk Design & Make Report