Evaluate FeatureScript
run_featurescriptEvaluate a read-only FeatureScript snippet against an Onshape Part Studio to run custom queries—such as face counts, distances, or selections—and return the result without modifying the document.
Instructions
Evaluate a read-only FeatureScript snippet against a Part Studio and return its result. Powerful for queries the other tools do not cover (face counts, distances, evaluating selections). It cannot modify the document. NOTE: lengths inside FeatureScript results are in METERS, not the configured unit.
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>",
"script": "<script>"
},
"name": "run_featurescript"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| script | Yes | A FeatureScript lambda, e.g. `function(context is Context, queries) { return size(evaluateQuery(context, qEverything(EntityType.FACE))); }`. | |
| 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 | |||