tscad GitHub

Sheet metal

<sheetMetal> builds a folded sheet-metal part and its flat pattern. You draw the base outline once and hang flanges off its edges, nesting them as deep as you like. Bends are exact cylindrical sections. The flat pattern unfolds each bend by its bend allowance and comes out as drawings ready for a laser and a press brake.

<part name="bracket" material="steel">
  <sheetMetal name="bracket" thickness={2} bendRadius={2} kFactor={0.44}>
    <flange>
      <rect w={60} h={40} />                          {/* the base outline (holes allowed) */}
      <circle d={5.5} />
      <edgeFlange edge="+y" length={50}>              {/* folds up 90° from the +y edge */}
        <circle d={5.5} x={30} y={30} />              {/* holes in the flange's own coordinates */}
        <edgeFlange edge="end" length={8} direction="down" />   {/* a return lip on its far edge */}
      </edgeFlange>
    </flange>
  </sheetMetal>
</part>
tscad build bracket.tsx -o bracket.step -o bracket.dxf    # folded part + flat pattern

Elements

Element
<sheetMetal thickness bendRadius? kFactor? name? flat? engraveNotes?>The part. bendRadius is the inside radius (default: the thickness), kFactor is the neutral-axis position (default 0.44). flat shows the flat pattern extruded instead of the folded part. engraveNotes also emits the bend labels as engraved text outlines. Placement props move the folded part.
<flange>The base: a closed 2D outline (any 2D shapes, <sketch>, constraint sketches, <svg>/<dxf>), holes nested inside it, and the edge flanges. It lies on z = 0 with material up to z = thickness.
<edgeFlange edge length angle? direction? bendRadius? inset? insetEnd? reliefs? reliefWidth? profile? corner? cornerGap? cornerRelief? cornerReliefSize?>Folds from edge by angle (default 90°, up to 180°) toward +Z (direction="up", default) or −Z ("down"), with length of flat beyond the bend. Its 2D children are holes in its own coordinates (x along the edge from the edge's start, y away from the bend); with profile they are its outline instead (see below). Its <edgeFlange>/<hem>/<jog> children hang from its own edges. corner* props: see Corners.
<hem edge length gap?>A 180° fold back over the sheet, bend radius gap / 2 (default gap: the thickness).
<jog edge offset length angle?>A Z-bend: up by angle, a web, back down. The web is sized so the jogged flange's bottom face sits offset above the parent's.

Edges.

Folding. The bend starts at the edge: the parent keeps its full outline, and the flange comes after the bend, so dimensions are "bend outside". The inner radius R faces the direction of the fold. Adjacent flanges (a tray's four walls) leave open corners by default (see Corners). inset / insetEnd shorten a flange along its edge. In that case rectangular bend reliefs (reliefWidth, default the thickness, depth R + T) are cut into the parent at the bend's ends; reliefs={false} turns them off.

Corners

Where two edge flanges hang from edges meeting at a square, convex corner of their parent (a tray's walls), corner on either decides how they meet:

cornerFoldedFlat pattern
"open" (default)a gap of R + T each waynothing added
"closed"both run on and meet on the corner's diagonal, mitred, cornerGap aparteach end extended to the inside of the mitre, R − gap/√2 (a laser cuts square)
"overlap"this flange runs on by R + T, flush with the neighbour's outside; the neighbour runs on R − cornerGapthe same extensions

cornerGap defaults to min(0.2, T / 4). Both flanges must be 90°, fold the same way, have the same radius and not be profiled. Otherwise the corner stays open, with a warning if a corner was asked for.

cornerRelief cuts a relief where the two bends meet:

Profiled flanges

With profile, an edge flange's 2D children are its outline: a tapered tab, a trapezoid, a flange with a notch, plus holes inside it. They are drawn in the flange's coordinates, and the outline must stand on the bend line: a straight edge along y = 0 from x = 0 to the flange's width, with nothing below it. length is optional (the outline's height).

<edgeFlange edge="end" direction="down" inset={10} profile>
  <polygon points={[[0, 0], [90, 0], [78, 12], [12, 12]]} />
  <circle d={4} x={45} y={6} />
</edgeFlange>

The flat pattern

Every bend is unfolded into a strip of width BA = θ·(R + K·T), its bend allowance. The flat pattern is the union of every flange's outline (holes and reliefs cut) and the bend strips, in the base's coordinates. It comes out in CompileResult.drawings:

DrawingLayerContent
<name>-flatcutthe outline and holes (exact lines and arcs)
<name>-bendsbendeach bend's centre line, an open path (Drawing.paths), plus a text note per bend, UP 90° R2 / DN 45° R2, beside it (Drawing.notes)
<name>-notesengraveonly with engraveNotes: the same labels as text outlines, for shops that laser-mark them

tscad build -o part.dxf (or .svg) writes them on those layers:

Checks (tests/sheet.test.tsx):

Examples

Limits