Set a variable
set_variableCreate or update Part Studio variables, including multiple values in one call, so changing a key dimension reshapes the whole model.
Instructions
Create a Part Studio variable, or change its value if it already exists. By default
model with variables: put every key dimension (diameter, length, pitch, wall thickness,
...) in a variable first, then use '#name' wherever the size is needed, so changing one
value reshapes the whole model. Pass variables to set many in one call.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"document_id": "<document_id>",
"element_id": "<element_id>"
},
"name": "set_variable"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| kind | No | Quantity type; only used when the variable is created. | length |
| name | No | Variable name: letters, digits and underscores, e.g. 'shank_diameter'. Referenced as '#shank_diameter'. Omit when using `variables`. | |
| value | No | A number (length in the configured unit, degrees for an angle), a string with a unit ('1.5 mm'), or an expression using other variables ('#shank_diameter / 2'). Omit when using by_option. | |
| by_option | No | Make the value depend on a configuration LIST input: {'Size': {'M10': 10, 'M18': 18}} gives 10 for M10 and 18 for M18. Every option of the input needs a value. Create the input first with set_configuration_input. Only when the user asks for configurations. | |
| variables | No | Set SEVERAL variables at once, e.g. {'d': 10, 'pitch': 1.5, 'head_h': 6.4}: existing ones change in ONE Onshape request, new ones are created. Instead of name / value. | |
| element_id | Yes | Element (tab) ID: the string after /e/ in the Onshape URL. Get it from get_document. | |
| document_id | Yes | Onshape document ID: the 24-character hex string after /documents/ in the document URL. Get it from list_documents. | |
| workspace_id | No | Workspace ID (the string after /w/ in the URL). Optional - defaults to the document's main workspace. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||