set_variable
Write or update an Onshape Variable Studio variable, enabling other part studios to reference it by #name in expressions such as dimensions and extrudes.
Instructions
Write or update a variable in a Variable Studio. elementId MUST be a Variable Studio element id (from create_variable_studio); writing to a Part Studio /variables endpoint 404s on modern docs. Other Part Studios in the same workspace can reference this variable as #name in any expression (sketch dimensions, extrude depths, etc.).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Variable name (FS identifier rules) | |
| type | No | FeatureScript variable type. Defaults to LENGTH. | |
| elementId | Yes | Variable Studio element ID (from create_variable_studio) | |
| documentId | Yes | Document ID | |
| expression | Yes | Variable expression (e.g., '30 mm', '0.75 in', '90 deg') | |
| description | No | Optional variable description | |
| workspaceId | Yes | Workspace ID |