A SheetMetalRule bundles the manufacturing parameters for a material: thickness, bend radius, k-factor, and relief behavior. You assign a rule to a component rather than defining thickness per body, similar to assigning a material.
There is no way to create a rule from scratch. Copy an existing rule from the design or library with the addByCopy method of SheetMetalRules, then edit the copy.
Note: The designSheetMetalRules collection is only available once the design contains sheet metal. In a new design, assign a library rule to the component's activeSheetMetalRule (see Assign a Rule to a Component, below), create the first sheet metal feature, and then copy rules into the design.
The following example copies the default library rule into a design that already contains sheet metal:
import adsk.core, adsk.fusion app = adsk.core.Application.get() design = adsk.fusion.Design.cast(app.activeProduct) # Copy the default library rule into the design. steelRule = design.librarySheetMetalRules.itemByName('Steel (mm)') newRule = design.designSheetMetalRules.addByCopy(steelRule, 'Steel (2 mm)') # The thickness and bendRadius properties are SheetMetalRuleValue objects. # Set either a numeric value (in centimeters) or an expression string. newRule.thickness.value = 0.2 newRule.bendRadius.expression = 'Thickness' # kFactor is a plain unitless ratio on the rule, not a SheetMetalRuleValue. newRule.kFactor = 0.44
Note: For SheetMetalRuleValue, the value property is in centimeters (Fusion internal length units). Setting newRule.thickness.value = 0.2 means 2 mm. To stay consistent with unit strings in the rest of your script, you can set expression instead (for example '2 mm') or use ValueInput.createByString('2 mm') where the API accepts ValueInput. See SheetMetalRuleValue Object.
Tip: Call addByCopy on designSheetMetalRules to store the copy in the document, or on librarySheetMetalRules to store it in the library. The Sheet Metal Rules Sample shows a complete example that copies within the library.
The most frequently used properties are thickness, bendRadius, and kFactor. The SheetMetalRule reference topic lists relief shape and size, the gap for miter, rip, and seam conditions, and other rule settings.
Code samples in this introduction are self-contained. Later examples re-fetch rules or edges instead of assuming a variable such as newRule still exists.
Assign the rule to the component where you will create sheet metal geometry, the same as in the UI. Set component.activeSheetMetalRule before creating base flanges or other features on that component. This works the same way for nested components. To create a flange that starts a new body in a nested component, also activate that component first (see Sheet Metal Features).
In a new design, assign a library rule:
rootComp.activeSheetMetalRule = design.librarySheetMetalRules.itemByName('Steel (mm)')
Once the design contains sheet metal, you can assign a design rule instead, such as the copy created above:
rootComp.activeSheetMetalRule = design.designSheetMetalRules.itemByName('Steel (2 mm)')
An imported solid, or a body built from ordinary extrudes and other non-sheet-metal features, is not sheet metal. Sheet metal features cannot operate on it until you convert it.
Call BRepBody.convertToSheetMetal, passing a face used to measure thickness and the rule to assign:
body = rootComp.bRepBodies.item(0) # Pass one of the large flat faces of the sheet; thickness is measured from it. # item(0) stands in for your own face selection. thicknessFace = body.faces.item(0) body.convertToSheetMetal(thicknessFace, rootComp.activeSheetMetalRule)
After conversion, body.isSheetMetal is True and the body works with flangeFeatures, hemFeatures, and the other sheet metal collections.
For the interactive workflow, see product help for Convert to Sheet Metal.