sketch_draw
Draw multiple sketch items with constraints and dimensions in one atomic call, automatically restoring the sketch if any step fails.
Instructions
Draw many sketch items, then constraints, then dimensions — one call, all or
nothing (on any error the sketch is restored and details = {phase:
geometry|constraints|dimensions, index, id}).
Coordinates: [x, y] sketch mm (numbers only — expressions like "w/2" are refused:
draw approximately and fix exact sizes with dimensions), {"model": [x, y, z]} model
mm (projected on the sketch plane; mind sketch_create's XZ pitfall), or a ref of an
existing point / curve end. A point given by ref is shared (no coincident needed).
Local ids: give an item id (letters, digits, _; not origin) and later items,
constraints and dimensions of THIS call can use id or id.<sub>; origin is the
sketch origin point. Local ids live one call only: the result refs maps every local
path to a real ref — use those refs in later calls.
Every item: {"kind", "id"?, "construction": false, ...}: | kind / mode | fields | sub-ids | | point | at | — | | line | start, end | start, end | | polyline | points (≥2), closed=false | e0..e{n-1} (edges), v0..v{n-1} | | rectangle two_point (default) | corner1, corner2 | bottom,right,top,left, bl,br,tr,tl | | rectangle center | center, corner | as two_point + center, diagonal | | rectangle three_point | p1, p2, p3 | e0..e3, v0..v3 | | circle center_radius (default) | center, radius | center | | circle two_point | p1, p2 (diameter ends) | center | | circle three_point | p1, p2, p3 | center | | arc three_point (default) | start, mid, end | start, end, center | | arc center_start_sweep | center, start, sweep (deg, + = CCW) | start, end, center | | arc tangent | from (curve end, e.g. "l1.end"), to | start, end, center | | ellipse | center, major_radius, minor_radius, angle=0 | center | | polygon | center, radius, sides 3..64, mode=inscribed|circumscribed, angle=0, constrain=true | e0.., v0.., center, circle | | spline | points (≥2 fit points), closed=false | start, end, fp0.. | | slot center_to_center (default) / overall | p1, p2, width | side0, side1, end0, end1, axis, c0, c1 | | text | text, height, corner, size=[w,h]?, font?, h_align=left, v_align=bottom | — |
constraints: [{"type": coincident (point, entity) | horizontal / vertical (line, or points [p1, p2]) | parallel / perpendicular / collinear (line1, line2) | tangent / equal / concentric (curve1, curve2) | midpoint (point, curve) | symmetry (entity1, entity2, line) | smooth (spline, curve) | fix (entity, fixed=true)}]. dimensions: [{"type": distance (line, or point1 + point2; orientation=aligned| horizontal|vertical) | offset (line, entity) | radial / diameter (curve) | angular (line1, line2) | ellipse_major / ellipse_minor (ellipse), "value": 25 (mm/deg) or "plate_w * 0.6", "parameter_name"?, "driven"=false, "text_at"?}]. A named dimension (parameter_name) can be used by later dimensions' expressions in the same call.
Returns {"sketch", "refs": {"r": {ref}, "r.bottom": {ref}, ...}, "constraints", "dimensions", "status" {fully_constrained, ...}, "profiles", "warnings"}.
Example — fully constrained 100 x 60 plate centred on the origin with a hole: sketch_draw(sketch=, items=[ {"kind": "rectangle", "mode": "center", "id": "r", "center": "origin", "corner": [50, 30]}, {"kind": "circle", "id": "h", "center": [30, 15], "radius": 4}], dimensions=[ {"type": "distance", "line": "r.bottom", "value": 100, "parameter_name": "plate_w"}, {"type": "distance", "line": "r.left", "value": "plate_w * 0.6"}, {"type": "diameter", "curve": "h", "value": 8}, {"type": "distance", "point1": "origin", "point2": "h.center", "orientation": "horizontal", "value": 30}, {"type": "distance", "point1": "origin", "point2": "h.center", "orientation": "vertical", "value": 15}]) -> status.fully_constrained = true; the plate profile has one inner loop.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| items | Yes | Geometry, drawn in order | |
| units | No | Unit of numeric coordinates and sizes | mm |
| sketch | Yes | Sketch ref (from sketch_create) | |
| dimensions | No | Applied after constraints, in order | |
| constraints | No | Applied after all items, in order | |
| return_profiles | No | Add the current profiles to the result (false = faster) |