Set a Part Studio variable
onshape_set_variableCreate or update a named variable in an Onshape document. Reference it by name in feature tools to keep dimensions in one place.
Instructions
Create or update a variable. Feature tools can then reference it by name (depth_variable, radius_variable, ...) so a dimension lives in one place. Uses the variable table where the account supports it and falls back to an assignVariable feature otherwise; result.route says which was used.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ws | Yes | Workspace id — the <ws> segment of the document URL. | |
| doc | Yes | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. | |
| elem | Yes | Element id (tab) — the <elem> segment of the document URL. | |
| name | Yes | Variable name, without the leading #. | |
| type | No | Variable type; inferred from the expression's units when omitted. | |
| expression | Yes | Value expression with units, e.g. "0.25 in" or "2 * #wall". | |
| description | No | What the variable means. |