Sheet Metal Flat Pattern Generator, K-Factor (Python CAD Automation)
A Python script (ezdxf) that turns a formed sheet-metal part into its flat blank. Enter the outside flange lengths, bend angles (up or down), material thickness, inside bend radius and K-factor, and it calculates the bend allowances, setbacks and developed length, then writes a DXF ready for laser or punch cutting.
Both drawings are real output from the same script:
- Hat-section bracket, 2 mm steel, 4 bends, K=0.33: flat blank 194.71 x 60 mm
- U-channel, 1.5 mm aluminium, 2 bends, K=0.4: flat blank 114.60 x 50 mm
Features:
K-factor method: BA = angle x (R + K x T), outside setback = tan(angle/2) x (R + T)
Bend lines placed at the centre of each bend zone, labelled with direction, angle and radius
Optional mounting holes, placed automatically on the mounting faces only
Formed profile drawn under the blank for a quick visual check
Warns when a flange is too short for the bend radius
Separate DXF layers for cut outline, bend lines, profile and notes
Result checked against a hand calculation
Tools: Python 3, ezdxf, matplotlib (preview rendering).
Published