build_closed_profile
Construct a closed sketch profile from an ordered list of line and arc segments in one call, validating loop closure before drawing to prevent open-loop extrusion failure. Leaves the sketch open for dimensions and relations.
Instructions
Perfil cerrado — construye un croquis a partir de UNA lista ordenada de segmentos (líneas y arcos) en UNA sola llamada, en vez de ~16 create_line/ create_arc sueltas. Valida que el lazo cierre ANTES de tocar SolidWorks (un perfil abierto mata la extrusión silenciosamente), luego dibuja todo y deja el croquis ABIERTO para que añadas cotas/relaciones y extruyas.
Uso típico CSWA Tool Block: pasa el outline completo (lados + chamfers
rectos + arcos R10/R20) como segments; el croquis queda listo para
add_sketch_relation / add_sketch_dimension / add_sketch_fillet y luego
extrude_sketch.
[en: Closed profile — build a sketch from ONE ordered list of segments (lines + arcs) in a single call instead of ~16 separate primitives. Validates the loop closes BEFORE any SW call (an open loop silently kills the extrude), then draws it and leaves the sketch OPEN to constrain.]
Args:
plane: sketch plane ("front"/"top"/"right", Spanish aliases, or a
reference-plane name).
segments: ordered loop. Each item is either
{"type":"line", "x1","y1","x2","y2"} or
{"type":"arc", "cx","cy","radius_mm","start_angle_deg",
"end_angle_deg","direction"("ccw"|"cw", default "ccw")}.
Each segment's end must meet the next segment's start.
close: if True (default), auto-add a closing line from the last
endpoint back to the first start when there's a gap. If False and
the loop isn't closed, raises.
name_hint: optional; reserved for future naming. Currently unused.
exact: if True (default), draw the loop in SolidWorks' exact mode
(ISketchManager.AddToDB) — segments land at their exact input
coordinates with NO automatic-relation inference, so the profile
does NOT drift 1-3 mm (and mass several %) as SW relaxes inferred
relations. This is the fix for the CSWA Tool Block drift: a true-arc
profile builds at the exact intended bbox and mass instead of
drifting by mm and grams. Pass exact=False ONLY if you deliberately
want SW to infer horizontal/vertical/tangent relations for later
parametric editing (and accept the drift). Best-effort: if the
driver can't toggle exact mode it falls back to inference-on.
variables: optional dict para coordenadas paramétricas — cualquier
coordenada de segmento puede ser un STRING como "A-29" o "B/2"
evaluado contra este dict (solo números, variables, + - * / y
paréntesis). Variante nueva = misma llamada con otro variables.
Returns {sketch_name, plane, segment_count, closed, vertices}. The sketch is left OPEN — add relations/dimensions, then extrude_sketch.
NOTE: call-count atomic, not SW-transactional — the up-front loop validation is the guardrail against a half-drawn open profile.
Related: create_sketch + create_line/create_arc (the primitives this composes); add_sketch_relation / add_sketch_dimension (constrain it after).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| close | No | ||
| exact | No | ||
| plane | Yes | ||
| segments | Yes | ||
| name_hint | No | ||
| variables | No |