| name | kalpataru-sketch-workflow |
| description | How to author a fully-defined SolidWorks sketch via Kalpataru. Geometric entity types, constraints, dimensions, and degree-of-freedom (DOF) tactics. |
Sketch workflow
A sketch is "fully defined" when DOF (degrees of freedom) = 0. Until then,
SolidWorks will let you extrude it but the resulting feature is fragile —
any later parametric change can warp it.
Geometric entity types
kalpataru_create_sketch accepts a list of entity dicts. Each has a type:
| Type | Fields | Notes |
|---|
line | start, end | A straight line. Auto-applies horizontal/vertical constraint if axis-aligned. |
construction_line | start, end | A reference line — not part of the boundary. |
circle | center, diameter | |
arc | center, radius, start_angle, end_angle | Angles in degrees. |
arc_3point | start, end, point3 | Better when you have three known points. |
rectangle | center, width, height | Centered rectangle. Most common form. |
corner_rectangle | corner1, corner2 | Two-corner form. |
polygon | center, diameter, sides | Regular polygon (hex, octagon, etc.). |
slot | center1, center2, width | Straight slot. |
ellipse | center, major_radius, minor_radius, rotation | Rotation in degrees. |
spline | points (list of [x,y]), closed | Through-point spline. |
polyline | points, closed | Connected line segments. |
point | position | Construction point. |
All coordinates are 2D [x, y] in millimetres, in the sketch's local
coordinate system.
The DOF rule
Every sketch entity adds DOF; every constraint and dimension removes some.
- A line has 4 DOF (x1, y1, x2, y2). A coincident point removes 2. A
horizontal/vertical constraint removes 1. A dimension removes 1.
- A circle has 3 DOF (cx, cy, r). Coincident-to-origin: 2. Diameter: 1.
- A rectangle has 4 DOF after auto-constraints (h/v on the sides).
Coincident center to origin: 2. Width and height: 2. → fully defined.
If you create a rectangle without anchoring it to the origin and without
dimensioning the size, DOF = 4. Anchor first (coincident to origin or a
known point), then dimension.
Constraint shorthand
The C# bridge auto-applies these constraints when it can:
- Lines parallel to X-axis → horizontal
- Lines parallel to Y-axis → vertical
- Two lines sharing an endpoint within 0.001mm → coincident
- Two circles with the same center within 0.001mm → concentric
- Symmetric pattern about origin → symmetric
So if you start your rectangle exactly at (−25, −25) and (25, 25), you
get horizontal/vertical/coincident-to-origin for free. The dimensions
(width: 50, height: 50) finish the constraint.
Inspecting sketch state
kalpataru_create_sketch returns:
sketch_name — for the next feature call
dof — should be 0 before extruding
profile_closed — true for closed boundaries (rectangles, polygons,
the four-line outline of a closed shape)
entities — [{name, type}], gives you names like Line1, Arc2 for
later constraint/dimension references
constraint_status — "fully_defined" / "under_defined" /
"over_defined"
If dof > 0, add more constraints. If over_defined, you have
conflicting constraints — undo and remove one.
Common patterns
Rectangle centered on origin, 50x50:
entities: [{"type":"rectangle","center":[0,0],"width":50,"height":50}]
Circle concentric to origin, Ø10:
entities: [{"type":"circle","center":[0,0],"diameter":10}]
Polygon, 6 sides, inscribed Ø20:
entities: [{"type":"polygon","center":[0,0],"diameter":20,"sides":6}]
Slot, 30mm long, 10mm wide:
entities: [{"type":"slot","center1":[-10,0],"center2":[10,0],"width":10}]
Closing the loop
For an extrude to work, the sketch boundary must be CLOSED. A rectangle is
inherently closed. Four separate lines forming a rectangle ARE closed if
the endpoints are coincident (within 0.001mm). The SDK's auto-coincident
will normally catch this — but if profile_closed: false is returned,
inspect the entities and verify the endpoints meet.