Flat Patterns

A flat pattern is the persistent unfolded counterpart to a sheet metal component. It is separate from the temporary Unfold feature in Sheet Metal Features.

The FlatPattern object exposes flattened geometry: bend lines, extent lines, and the top, bottom, and side faces of the flat body.

Create a Flat Pattern

Call Component.createFlatPattern on the component that owns the sheet metal body. Pass a face to hold stationary while the rest unfolds.

import adsk.core, adsk.fusion

app = adsk.core.Application.get()
design = adsk.fusion.Design.cast(app.activeProduct)
rootComp = design.rootComponent
doc = app.activeDocument
body = rootComp.bRepBodies.item(0)

stationaryFace = body.faces.item(0)
flatPattern = rootComp.createFlatPattern(stationaryFace)

The createFlatPattern method returns the FlatPattern object directly. It fails if the component already has a flat pattern. To get an existing flat pattern, use Component.flatPattern, which returns None if the component does not have one.

FlatPattern is a timeline feature. Useful properties and methods include:

Member Purpose
flatBody Flattened BRepBody
bendLinesBody Bend line geometry
extentLinesBody Extent lines
topFace, bottomFace, sideFaces Faces on the flat body
foldedBody Original folded body
getBendInfo(bendEdge) Fold direction and angle for a bend edge

Sketch on the Flat Pattern

Each flat pattern has its own FlatPatternProduct in the document. Sketches on the flat pattern use that product's FlatPatternComponent, from FlatPatternProduct.rootComponent. No property leads from a FlatPattern to its product, so find the product in the document's products collection by matching the flat pattern's entityToken:

flatPattern = rootComp.flatPattern

# Find the FlatPatternProduct that belongs to this flat pattern.
fpComponent = None
for product in doc.products:
    fpProduct = adsk.fusion.FlatPatternProduct.cast(product)
    if fpProduct and fpProduct.flatPattern.entityToken == flatPattern.entityToken:
        fpComponent = adsk.fusion.FlatPatternComponent.cast(fpProduct.rootComponent)
        break

sketchOnFlat = fpComponent.sketches.add(flatPattern.topFace)

# Draw a 5 mm radius circle on the flat pattern. Sketch coordinates are in centimeters.
sketchOnFlat.sketchCurves.sketchCircles.addByCenterRadius(
    adsk.core.Point3D.create(0, 0, 0), 0.5)

Read Bend Information

To read the fold direction and angle of each bend, call getBendInfo on each edge of the flat pattern's bendLinesBody:

import math

flatPattern = rootComp.flatPattern
bendLinesBody = flatPattern.bendLinesBody
for bendEdge in bendLinesBody.edges:
    ok, isBendUp, bendAngleRad = flatPattern.getBendInfo(bendEdge)
    if ok:
        print(f'Bend angle: {math.degrees(bendAngleRad):.1f} deg, up={isBendUp}')

Tip: Workflow order is (1) build the sheet metal body in the design, (2) createFlatPattern, (3) read bends and sketch on FlatPatternComponent.

Samples

The Sheet Metal category on API Samples includes complete sample scripts for sheet metal workflows.

Related API Reference