add_global_variable
Add a named global variable equation in SolidWorks, allowing sketch and feature dimensions to reference parameters like A, B, C for parametric parts without rebuilding.
Instructions
Agregar variable global (ecuación) — declara un parámetro nombrado como "A", "B", "C" que las dimensiones de croquis y de feature pueden referenciar mediante una ecuación. Requisito habitual para piezas paramétricas como el CSWA Tool Block donde A, B, C deben modificarse entre pasos sin reconstruir.
[en: Add a global variable (equation) — declare a named parameter like "A", "B", "C" that sketch and feature dimensions can reference via an equation. Standard requirement for parametric parts like the CSWA Tool Block where A, B, C must change across steps without rebuilding.]
Args: name: Variable name (LHS of the equation). Cannot contain quotes, =, comma, or @. SW convention: short uppercase, e.g. "A", "B". value: The numeric value in the specified units. units: "mm" (default, length), "deg" (angle), or "raw" (dimensionless). SW stores values internally as meters / radians; this argument controls the equation suffix and the internal conversion.
Returns dict with: name, value, units, equation (raw SW string like '"A" = 81mm'), index (0-based position in the equation table).
Binding a dim to this variable: after creating the global, ADD ANOTHER EQUATION whose LHS is the dim name and whose RHS is the variable: add_global_variable("D1@Croquis1", '"A"', units="raw") (Pass an expression string; the equation manager accepts dim-paths on the LHS in addition to variable names.)
To change the value later, use set_global_variable. Do NOT call
add_global_variable again with the same name.
Related: set_global_variable (modify existing), modify_dimension (feature dims only, not global vars).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| units | No | mm | |
| value | Yes |