Skip to content
FlywheelCAD

Examples

Bracket

A mounting bracket driven by four variables. The sketch is fully constrained: the solver badge reads Fully constrained, and nothing moves until you change a dimension.

The bracket sketch in FlywheelCAD: a trapezoid with a hole, dimensioned WIDTH = 80, HEIGHT = 50, SLANT = 105°, hole radius 4.5, positioned 28 and 25 from the edges.
The sketch. Each dimension shows the variable that drives it.
The bracket extruded 6 mm with rounded edges and one mounting hole.
Extruded 6 mm, edges rounded by the extrude itself.

What it shows

  • A rough outline pinned by geometric constraints: coincident with the origin, horizontal, parallel, vertical. The right edge's lean is an angle dimension.
  • Dimensions bound to shared variables: WIDTH, HEIGHT, SLANT, HOLE_DIA. Change one in the Variables panel and the sketch re-solves.
  • New in 0.35: points written with variables (cad.point2d(WIDTH, 0.0)) as the starting guess, and a hole whose radius expression keeps its link (cad.circle2d(hc, HOLE_DIA / 2.0) adds the radius dimension for you).

The code

WIDTH    = cad.variable(80.0, driving=True)   # overall bracket width  (mm)
HEIGHT   = cad.variable(50.0, driving=True)   # overall bracket height (mm)
SLANT    = cad.variable(105.0, driving=True)  # angle of the right edge (deg)
HOLE_DIA = cad.variable(9.0, driving=True)    # mounting-hole diameter (mm)

A = cad.point2d(0.0, 0.0)             # bottom-left  (origin corner)
B = cad.point2d(WIDTH, 0.0)           # bottom-right
C = cad.point2d(WIDTH - 12.0, HEIGHT) # top-right (pulled in by the slant)
D = cad.point2d(0.0, HEIGHT)          # top-left

cad.coincident(A, origin_xy)          # the origin corner sits ON the origin
cad.horizontal(l_bottom)              # bottom edge is level …
cad.parallel(l_top, l_bottom)         # … and the top edge is parallel to it
cad.vertical(l_left)                  # left edge is plumb (so, square to the bottom)

cad.distance(A, B, WIDTH)             # bottom edge length  = WIDTH
cad.distance(A, D, HEIGHT)            # left edge length    = HEIGHT
cad.angle(l_bottom, l_right, SLANT)   # lean of the right edge

hc   = cad.point2d(WIDTH * 0.35, HEIGHT / 2.0)
hole = cad.circle2d(hc, HOLE_DIA / 2.0)
cad.point_line_distance(hc, l_bottom, HEIGHT / 2.0)  # centred top-to-bottom
cad.point_line_distance(hc, l_left, WIDTH * 0.35)    # 35% in from the left edge

Every constraint you click in the sketch is one line here, and every line here shows up as a constraint. Excerpt from 01_sketch_bracket.fwcad/main.py; the lines between draw the four edges.

The bracket is project 1 of 5 in the Showcase bundle. Open 01_sketch_bracket.fwcad in FlywheelCAD.