onshape
v0.3.0Drive Onshape CAD from an assistant: documents, sketches, solid features, assemblies and exports.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
onshape_login Sign in to Onshape
Sign in to Onshape by opening a browser. method='api_key' (default) opens a local page that links to the Onshape developer key page and accepts the pasted key pair. method='oauth' runs the OAuth 2.0 authorization-code flow against an app you registered in the Onshape developer portal. The credential is verified against Onshape and stored in the OS keychain. Returns immediately with status 'pending' if the user has not finished yet — poll with onshape_login_status.
| Parameter | Type | Description |
|---|---|---|
base_url | string | Onshape API base URL (default https://cad.onshape.com). |
client_id | string | OAuth client id; also read from ONSHAPE_OAUTH_CLIENT_ID. |
client_secret | string | OAuth client secret; also read from ONSHAPE_OAUTH_CLIENT_SECRET. |
method | string | Login method (default api_key). |
oauth_url | string | OAuth server (default https://oauth.onshape.com). |
port | integer | Loopback port for the callback (OAuth default 8471). |
scope | string | Space-separated OAuth scopes, when the app needs them stated. |
store | string | Where to keep the credential: auto (keychain, else file), keychain, or file. |
wait_seconds | integer | Seconds to wait for the browser before returning (default 20). |
onshape_login_status Check the pending Onshape login
Wait for, and report on, the login started by onshape_login. Call this repeatedly while the user is in the browser; each call waits up to wait_seconds before returning.
| Parameter | Type | Description |
|---|---|---|
wait_seconds | integer | Seconds to wait for the browser before returning (default 20). |
onshape_set_api_key Store an Onshape API key pair
Store an Onshape access key and secret key directly, without a browser. Use when the user already has a key pair from https://cad.onshape.com/user/developer/apiKeys. The pair is verified against Onshape before it is saved.
| Parameter | Type | Description |
|---|---|---|
access_key * | string | Onshape access key. |
secret_key * | string | Onshape secret key. |
base_url | string | Onshape API base URL (default https://cad.onshape.com). |
store | string | Where to keep the credential: auto (keychain, else file), keychain, or file. |
onshape_auth_status Show Onshape sign-in status
Report which Onshape credential is active, where it came from and whether it still works. Secrets are redacted.
| Parameter | Type | Description |
|---|---|---|
verify | boolean | Also make a live API call to confirm the credential (default true). |
onshape_logout Forget stored Onshape credentials
Delete the credential this server stored (keychain entry and config file). Credentials coming from environment variables or from an existing onshape-cli install are not touched.
onshape_list_documents List Onshape documents
List documents visible to the signed-in user, most recently modified first.
| Parameter | Type | Description |
|---|---|---|
filter | string | Which documents to list (default all). |
limit | integer | How many to return (default 20). |
sort_by | string | Sort column, e.g. modifiedAt or name (default modifiedAt). |
sort_order | string | Sort direction (default desc). |
onshape_search_documents Search Onshape documents
Find documents by name. Search before creating, so repeated runs do not make duplicates.
| Parameter | Type | Description |
|---|---|---|
query * | string | Text to match against document names. |
limit | integer | How many to return (default 20). |
onshape_get_document Get an Onshape document
Read one document's metadata, including its default workspace id.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
onshape_get_document_summary Summarize an Onshape document
Document metadata plus every workspace and the elements (tabs) inside each — the fastest way to orient in an unfamiliar document and collect the ids other tools need.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
onshape_create_document Create an Onshape document
Create a document. Free Onshape accounts may only create public documents, so pass public=true there. The result carries the new document id and its default workspace id.
| Parameter | Type | Description |
|---|---|---|
name * | string | Document name. |
description | string | Document description. |
public | boolean | Make the document public (required on free accounts). |
onshape_update_document Rename an Onshape document
Change a document's name or description.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
description | string | New description. |
name | string | New name. |
onshape_delete_document Delete an Onshape document
Move a document to the trash. This affects the whole document, not a single tab.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
onshape_get_workspaces List workspaces
List a document's workspaces (branches).
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
onshape_get_elements List elements in a workspace
List the elements (tabs) in a workspace: Part Studios, assemblies, drawings, Feature Studios.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
type | string | Only return elements of this type. |
onshape_find_part_studios Find Part Studios by name
List the Part Studios in a workspace, optionally filtered by a substring of the name.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Case-insensitive substring to match. |
onshape_list_versions List document versions
List the immutable versions of a document, newest first.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
onshape_create_version Create a document version
Snapshot the workspace as an immutable version. Do this before restructuring an existing design: it is the only way back to the previous state, and drawings must reference a version.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
name * | string | Version name, e.g. what is about to change. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
description | string | Why this snapshot was taken. |
onshape_delete_element Delete an element
Delete one element (tab) from a workspace.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_create_part_studio Create a Part Studio
Add a Part Studio tab to a workspace. The new element id is at result.response.id.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
name * | string | Tab name. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_features List Part Studio features
The full feature tree with each feature's id, type, parameters and regeneration state. Large — prefer onshape_measure or onshape_get_parts when you only need the result of the tree.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
configuration | string | Encoded configuration string from onshape_encode_configuration. |
onshape_get_feature_specs Get feature specifications
The parameter ids, enum names and defaults Onshape expects for every feature type in this Part Studio. Read this before hand-writing a payload for onshape_add_feature.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_sketch_info Get sketch geometry
Entities and solved geometry for every sketch in a Part Studio, or for one sketch.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
sketch | string | Limit to this sketch feature id. |
onshape_get_body_details Get body topology
Bodies, faces and edges with their deterministic ids — the source for explicit edge selection.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_parts List parts
The parts a Part Studio produces, with part ids for export and assembly insertion.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_mass_properties Get mass properties
Volume, mass, centroid and inertia for the Part Studio's bodies.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
configuration | string | Encoded configuration string from onshape_encode_configuration. |
onshape_measure Measure the model
Body count, overall bounding box in inches and total volume. Use this to check a model matches its intended dimensions before exporting.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_clearance Measure clearance between two bodies
Minimum distance between two solid bodies in the same Part Studio, each named by part id or by the feature that created it. 0 (clear: false) means they touch or overlap, so this is also the interference check — e.g. a bracket against a dummy servo body. Returns inches and millimetres, plus the closest point on each body.
| Parameter | Type | Description |
|---|---|---|
a * | object | The first body: give exactly one of part or feature. |
b * | object | The second body: give exactly one of part or feature. |
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_validate_part_studio Validate a Part Studio
Count parts and bodies, and fail when the counts do not match the expectations you pass. A cheap regression check after a run of feature edits.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
expect_bodies | integer | Fail unless it has exactly this many bodies. |
expect_parts | integer | Fail unless the Part Studio has exactly this many parts. |
onshape_add_feature Add a raw feature
Post a hand-written BTM feature payload to a Part Studio. The escape hatch for feature types this server has no dedicated tool for — read onshape_get_feature_specs first.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
feature * | object | The feature JSON, usually a BTFeatureDefinitionCall-1406 envelope. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_update_feature Update a feature
Replace an existing feature's payload, e.g. to change a dimension. Post the whole feature JSON.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
feature * | object | The full replacement feature JSON. |
feature_id * | string | Id of the feature to replace. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_delete_feature Delete a feature
Remove one feature from the tree. Features added after it may fail to regenerate.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
feature_id * | string | Id of the feature to delete. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_rollback Move the rollback bar
Set the rollback index so features after it are suppressed. Index 0 rolls back to before the first feature.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
index * | integer | Rollback index; use a large number to roll fully forward. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_eval_featurescript Evaluate FeatureScript
Run a FeatureScript function against the Part Studio and return its decoded value. The general-purpose way to inspect geometry: 'function(context is Context, queries) { ... }'.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
script * | string | A FeatureScript function expression taking (context, queries). |
ws * | string | Workspace id — the <ws> segment of the document URL. |
raw | boolean | Return Onshape's raw response instead of the decoded value. |
onshape_sketch_rectangle Sketch a rectangle
Add a sketch holding one closed rectangle, ready to extrude. Corners are opposite, in inches.
| Parameter | Type | Description |
|---|---|---|
corner1 * | First corner. As [x, y] inches or "x,y". | |
corner2 * | Opposite corner. As [x, y] inches or "x,y". | |
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name shown in the tree (default "Sketch"). |
plane | string | Default plane to sketch on (default Front). |
plane_feature | string | Sketch on a face created by this feature id instead of a default plane. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_sketch_circle Sketch a circle
Add a sketch holding one circle.
| Parameter | Type | Description |
|---|---|---|
center * | Circle centre. As [x, y] inches or "x,y". | |
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
radius * | number | Radius in inches. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name shown in the tree (default "Sketch circle"). |
plane | string | Default plane to sketch on (default Front). |
plane_feature | string | Sketch on a face created by this feature id instead of a default plane. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_sketch_line Sketch a line
Add a sketch holding one line segment. A line alone encloses no region, so it cannot be extruded.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
end * | End point. As [x, y] inches or "x,y". | |
start * | Start point. As [x, y] inches or "x,y". | |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name shown in the tree (default "Sketch"). |
plane | string | Default plane to sketch on (default Front). |
plane_feature | string | Sketch on a face created by this feature id instead of a default plane. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_sketch_circle_axis Sketch a circle with a revolve axis
Add a sketch with a circle profile and a construction line. onshape_revolve spins the profile around that construction line, which is how you get a torus or a ring.
| Parameter | Type | Description |
|---|---|---|
axis_end * | Axis end. As [x, y] inches or "x,y". | |
axis_start * | Axis start. As [x, y] inches or "x,y". | |
center * | Circle centre. As [x, y] inches or "x,y". | |
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
radius * | number | Radius in inches. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name shown in the tree (default "Sketch circle and axis"). |
plane | string | Default plane to sketch on (default Front). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_create_sketch Sketch arbitrary entities
Add a sketch from a list of entities: lines, circles, rectangles and arcs. Use this when the single-shape sketch tools cannot express the profile. Close the profile if you intend to extrude it.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
entities * | array | Entities making up the sketch. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name shown in the tree (default "Sketch"). |
plane | string | Default plane to sketch on (default Front). |
plane_feature | string | Sketch on a face created by this feature id instead of a default plane. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_sketch_candy_cane_path Sketch a hooked sweep path
Add a sketch of a straight stem joined to a hooked arc, approximated by segments — a ready-made path for onshape_sweep.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
hook_radius * | number | Radius of the hook, inches. |
straight_height * | number | Length of the straight stem, inches. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
bottom | number | Y of the stem's bottom (default 0). |
hook_angle | number | Sweep of the hook in degrees (default 210). |
name | string | Feature name shown in the tree (default "Candy cane centerline"). |
plane | string | Default plane to sketch on (default Front). |
segments | integer | Total segments used to approximate the path (default 24). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
x | number | X position of the stem (default 0). |
onshape_extrude Extrude a sketch
Extrude the closed regions of a sketch into a solid. op=NEW makes a body, ADD merges into existing bodies, REMOVE cuts them, INTERSECT keeps the overlap. end_type picks blind, symmetric or through-all; opposite flips the direction.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
sketch * | string | Feature id of the sketch to extrude. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
depth | number | Extrusion depth in inches; the total depth when symmetric. Required unless THROUGH_ALL or depth_variable. |
depth_variable | string | Use a Part Studio variable (by name) for the depth instead. |
end_type | string | BLIND goes `depth` along the sketch normal (default); SYMMETRIC goes `depth` in total, half each side of the sketch plane; THROUGH_ALL goes past every body and ignores `depth`. |
name | string | Feature name shown in the tree (default "Extrude"). |
op | string | NEW makes a new body; ADD/REMOVE/INTERSECT combine with existing bodies (default NEW). |
opposite | boolean | Go against the sketch normal instead of along it. Not with SYMMETRIC. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_hole Cut a hole
Extrude a sketch as a cut (op=REMOVE). Sketch a circle first, then cut it through the body: end_type THROUGH_ALL needs no depth. A sketch on a body's face points out of the body, so pass opposite to cut into it.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
sketch * | string | Feature id of the sketch to cut with. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
depth | number | Cut depth in inches; the total depth when symmetric. Required unless THROUGH_ALL or depth_variable. |
depth_variable | string | Use a Part Studio variable for the depth. |
end_type | string | BLIND goes `depth` along the sketch normal (default); SYMMETRIC goes `depth` in total, half each side of the sketch plane; THROUGH_ALL goes past every body and ignores `depth`. |
name | string | Feature name shown in the tree (default "Hole"). |
opposite | boolean | Go against the sketch normal instead of along it. Not with SYMMETRIC. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_thicken Thicken a sketch
Give a sketch region a wall thickness instead of a solid depth.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
sketch * | string | Feature id of the sketch to thicken. |
thickness * | number | Thickness in inches. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
midplane | boolean | Grow symmetrically about the sketch plane. |
name | string | Feature name shown in the tree (default "Thicken"). |
op | string | NEW makes a new body; ADD/REMOVE/INTERSECT combine with existing bodies (default NEW). |
opposite | boolean | Thicken in the opposite direction. |
thickness_variable | string | Use a Part Studio variable for the thickness. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_revolve Revolve a sketch
Revolve a sketch profile around an axis. With no axis given, the sketch's own construction line is used (see onshape_sketch_circle_axis); otherwise pass axis_ids or an axis query.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
sketch * | string | Feature id of the sketch holding the profile. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
angle | number | Revolve angle in degrees (default 360). |
axis | string | FeatureScript query selecting the axis. |
axis_ids | array | Deterministic ids of the axis entity. |
name | string | Feature name shown in the tree (default "Revolve"). |
op | string | NEW makes a new body; ADD/REMOVE/INTERSECT combine with existing bodies (default NEW). |
type | string | FULL revolves all the way around (default FULL when an axis is given). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_sweep Sweep a profile along a path
Sweep the closed regions of one sketch along the edges of another.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
path * | string | Feature id of the path sketch. |
profile * | string | Feature id of the profile sketch. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name shown in the tree (default "Sweep"). |
op | string | NEW makes a new body; ADD/REMOVE/INTERSECT combine with existing bodies (default NEW). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_fillet Fillet edges
Round the selected edges. Name the edges with one of: edges (ids), query (FeatureScript), feature (every edge that feature made), all, or circular.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
all | boolean | Select all edges of all solid bodies. |
circular | boolean | Select only circular edges. |
edges | array | Explicit deterministic edge ids, from onshape_get_edges. |
feature | string | Select every edge created by this feature id. |
name | string | Feature name shown in the tree (default "Fillet"). |
query | string | FeatureScript query, e.g. query = qCreatedBy(makeId("FID"), EntityType.EDGE); |
radius | number | Fillet radius in inches (default 0.1). |
radius_variable | string | Use a Part Studio variable for the radius. |
type | string | Fillet type (default EDGE). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_chamfer Chamfer edges
Bevel the selected edges. Selection works exactly as for onshape_fillet.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
all | boolean | Select all edges of all solid bodies. |
angle | number | Angle in degrees, for type=OFFSET_ANGLE. |
circular | boolean | Select only circular edges. |
edges | array | Explicit deterministic edge ids, from onshape_get_edges. |
feature | string | Select every edge created by this feature id. |
name | string | Feature name shown in the tree (default "Chamfer"). |
query | string | FeatureScript query, e.g. query = qCreatedBy(makeId("FID"), EntityType.EDGE); |
type | string | Chamfer type (default EQUAL_OFFSETS). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
width | number | Chamfer width in inches (default 0.1). |
width_variable | string | Use a Part Studio variable for the width. |
onshape_shell Shell a body
Hollow the body out to a wall thickness, removing the selected faces to open it.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
faces | array | Deterministic ids of faces to remove. |
name | string | Feature name shown in the tree (default "Shell"). |
outward | boolean | Thicken outward instead of inward. |
query | string | FeatureScript query selecting the faces to remove. |
thickness | number | Wall thickness in inches (default 0.125). |
thickness_variable | string | Use a Part Studio variable for the thickness. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_draft Draft faces
Taper faces away from a neutral plane — the usual requirement for moulded or cast parts.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
faces * | string | FeatureScript query selecting the faces to draft. |
neutral * | string | FeatureScript query selecting the neutral plane or face. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
angle | number | Draft angle in degrees (default 3). |
name | string | Feature name shown in the tree (default "Draft"). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_boolean Boolean bodies
Combine bodies: UNION, SUBTRACTION or INTERSECTION. Subtraction also needs the targets query.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
keep_tools | boolean | Keep the tool bodies after the operation. |
name | string | Feature name shown in the tree (default "Boolean"). |
op | string | Boolean operation (default UNION). |
targets | string | FeatureScript query selecting the target bodies (SUBTRACTION). |
tool_ids | array | Deterministic ids of the tool bodies. |
tools | string | FeatureScript query selecting the tool bodies. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_boolean_union Union every body
Merge all modifiable solid bodies into one. The usual cleanup before exporting a single part.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name shown in the tree (default "Union bodies"). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_mirror Mirror geometry
Mirror parts, bodies or faces across a plane.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
entities * | string | FeatureScript query selecting what to mirror. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name shown in the tree (default "Mirror"). |
plane_ids | array | Deterministic id of the mirror plane, e.g. JCC for Front. |
plane_query | string | FeatureScript query selecting the mirror plane. |
type | string | What kind of thing is being mirrored (default PART). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_linear_pattern Linear pattern
Repeat geometry along a direction, at a fixed spacing.
| Parameter | Type | Description |
|---|---|---|
count * | integer | Total number of instances, including the original. |
distance * | number | Spacing between instances, inches. |
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
entities * | string | FeatureScript query selecting what to pattern. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
direction | string | FeatureScript query selecting the direction entity. |
direction_ids | array | Deterministic id of an edge giving the direction. |
name | string | Feature name shown in the tree (default "Linear Pattern"). |
opposite | boolean | Pattern in the opposite direction. |
type | string | What kind of thing is patterned (default PART). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_circular_pattern Circular pattern
Repeat geometry around an axis.
| Parameter | Type | Description |
|---|---|---|
count * | integer | Total number of instances, including the original. |
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
entities * | string | FeatureScript query selecting what to pattern. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
angle | number | Total angle covered, degrees (default 360). |
axis | string | FeatureScript query selecting the axis. |
axis_ids | array | Deterministic id of the axis entity. |
equal_spacing | boolean | Space instances evenly over the angle (default true). |
name | string | Feature name shown in the tree (default "Circular Pattern"). |
type | string | What kind of thing is patterned (default PART). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_offset_plane Create an offset plane
Add a construction plane offset from a default plane, a face, or another plane.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
base_ids | array | Deterministic ids of the plane or face to offset from. |
base_plane | string | Default plane to offset from (default Front). |
base_query | string | FeatureScript query selecting the base plane or face. |
name | string | Feature name shown in the tree (default "Offset plane"). |
offset | number | Offset distance in inches (default 1). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_get_edges List edges
Every edge of every solid body, with its deterministic id, owning body, type, and for circles and arcs the radius and centre (inches).
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_find_circular_edges Find circular edges
Circular edges (full circles and arcs), optionally only those matching a radius, with each one's centre in inches — the usual way to pick hole rims to fillet, or to check where the holes are.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
radius | number | Only return edges with this radius, in inches. |
tolerance | number | Radius match tolerance in inches (default 0.001). |
onshape_find_edges_by_feature Find edges created by a feature
Deterministic ids of the edges a given feature created, evaluated by Onshape.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
feature * | string | Feature id whose edges you want. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_variables List Part Studio variables
The variable table of a Part Studio: names, expressions and descriptions.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_set_variable Set a Part Studio variable
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. On the feature route an existing variable of the same name is rewritten in place, so features built after it pick up the new value (result.action is updated or created).
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
expression * | string | Value expression with units, e.g. "0.25 in" or "2 * #wall". |
name * | string | Variable name, without the leading #. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
description | string | What the variable means. |
type | string | Variable type; inferred from the expression's units when omitted. |
onshape_get_configuration Get element configuration
The configuration parameters an element exposes, with their ids and allowed values.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_encode_configuration Encode a configuration
Turn configuration parameter values into the encoded string other tools accept as `configuration`.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
params * | array | Parameter ids and the values to set. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_export_stl Export STL
Export the Part Studio as STL, for 3D printing. The file is in millimetres by default, which is what slicers assume; STL carries no unit, so only change `units` if the consumer expects otherwise. Measure the model before exporting it.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
ascii | boolean | Write ASCII STL instead of binary. |
configuration | string | Encoded configuration string. |
out | string | Output file path (default onshape-<timestamp>.stl in the output directory). |
resolution | string | Tessellation quality (default medium). |
units | string | STL units (default millimeter). |
onshape_export Export CAD format
Export through Onshape's translation service: STEP, IGES, 3MF, PARASOLID, SOLIDWORKS and others. Slower than STL because the translation is queued server-side.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
configuration | string | Encoded configuration string. |
format | string | Format name, e.g. STEP, IGES, 3MF, PARASOLID (default STEP). |
kind | string | Element kind being exported (default partstudios). |
out | string | Output file path (default onshape-<timestamp>.<format> in the output directory). |
onshape_shaded_view Render the model
Render the element server-side and return the image. Unlike a thumbnail this is generated on demand, so it always shows the current geometry — use it to check a model visually before exporting.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
configuration | string | Encoded configuration string. |
height | integer | Image height in pixels (default 340). |
kind | string | Element kind being exported (default partstudios). |
no_edges | boolean | Hide edges in the render. |
out | string | Output PNG path (default onshape-<timestamp>.png in the output directory). |
return_image | boolean | Also return the PNG inline (default true). |
view_matrix | string | 3x4 row-major camera matrix as 12 comma-separated numbers (default isometric). |
width | integer | Image width in pixels (default 600). |
onshape_get_thumbnail Download the element thumbnail
Save Onshape's stored thumbnail. Thumbnails are generated asynchronously and lag edits — prefer onshape_shaded_view to see the current state.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
out | string | Output PNG path (default onshape-thumb-<timestamp>.png). |
return_image | boolean | Also return the PNG inline (default true). |
size | string | Thumbnail size, e.g. "600x340" or "300x300" (default 600x340). |
onshape_thumbnail_info List thumbnail sizes
The thumbnail sizes Onshape has rendered for this element, with their hrefs.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_create_assembly Create an assembly
Add an assembly tab to a workspace.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
name * | string | Tab name. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_assembly Get assembly structure
The assembly's instances, occurrences, mate features and mate connectors.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
include_mate_connectors | boolean | Include mate connectors (default true). |
include_mate_features | boolean | Include mate features (default true). |
include_non_solids | boolean | Include non-solid instances (default false). |
onshape_insert_instance Insert an instance
Insert a part, a whole Part Studio or another assembly into an assembly. Insert from a version when pulling from a different document.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
src_elem * | string | Element id of the source Part Studio or assembly. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
configuration | string | Encoded configuration for the inserted element. |
fixed | boolean | Fix the new instance in place, to ground the assembly. Onshape has no public call to fix or unfix an instance afterwards; to change it, insert again and delete the old instance. |
is_assembly | boolean | The source element is an assembly. |
part | string | Part id, to insert a single part. |
src_doc | string | Source document id (defaults to the target document). |
src_version | string | Source version id, required when inserting across documents. |
whole_studio | boolean | Insert every part of the source Part Studio. |
onshape_delete_instance Delete an instance
Remove one instance from an assembly by its occurrence node id.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
node * | string | Occurrence node id of the instance. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_transform_instance Transform instances
Apply a 4x4 row-major transform (16 numbers, metres) to the given occurrence paths.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
paths * | array | Occurrence paths, each an array of node ids. |
transform * | array | Row-major 4x4 transform matrix. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
absolute | boolean | Treat the transform as absolute rather than relative. |
onshape_get_assembly_features List assembly features
The mates, mate connectors, groups and relations defined in an assembly, with their feature ids, payloads and regeneration states.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_assembly_mate_connector Add a mate connector
Place an implicit mate connector on an instance by inference (CENTROID, TOP, ...). Its feature id is what onshape_assembly_mate then joins.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
occurrence * | string | Occurrence id of the instance to attach to. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
inference | string | Inference type, e.g. CENTROID, TOP, MID_PLANE (default CENTROID). |
name | string | Feature name (default "Mate connector"). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_assembly_mate Add a mate
Join two mate connectors with a mate: FASTENED, REVOLUTE, SLIDER, CYLINDRICAL, PLANAR, and so on. Each connector is an assembly-level mate connector's feature id, or a Part Studio mate connector given as {path: [instance id], connector: feature id} from onshape_get_assembly. The mate's value measures the first connector against the second, so list the moving part first.
| Parameter | Type | Description |
|---|---|---|
connectors * | array | The mate connectors to join, moving part first. |
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name (default "Mate"). |
type | string | Mate type (default FASTENED). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_assembly_group Group instances
Lock several instances together without individual mates.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
occurrences * | array | Occurrence ids to group. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
name | string | Feature name (default "Group"). |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_assembly_add_feature Add a raw assembly feature
Post a hand-written assembly feature payload — the escape hatch for mate types with no tool here.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
feature * | object | The assembly feature JSON. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_update_assembly_feature Update an assembly feature
Replace an assembly feature's payload — a mate's type, connectors or limits, a relation's ratio. Post the whole feature JSON, e.g. as onshape_get_assembly_features returns it, inside a BTFeatureDefinitionCall-1406 envelope.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
feature * | object | The full replacement feature JSON. |
feature_id * | string | Id of the feature to replace. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
validate | boolean | Re-read the feature list afterwards and fail if the feature regenerated with an error (default true). |
onshape_delete_assembly_feature Delete an assembly feature
Remove a mate, mate connector, group or relation. Relations on a deleted mate stop solving.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
feature_id * | string | Id of the feature to delete. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_assembly_relation Relate two mates
Couple mates so one drives the other: GEAR (two revolutes, ratio), RACK_AND_PINION (a revolute and a slider, distance per revolution), SCREW (one cylindrical mate, distance per revolution) or LINEAR (two sliders, ratio). Each mate's degree of freedom follows from its type; cylindrical mates contribute whichever the relation needs. Mates missing the parameter relations need (made by hand-written payloads) are completed first and listed in completedMates. Fails if the relation does not regenerate.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
mates * | array | Mate feature ids: two, or one for SCREW. |
type * | string | Relation type. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
distance_per_revolution | number | RACK_AND_PINION and SCREW: travel per full turn, inches. A pinion's is its pitch circumference. |
dofs | array | Override the degree of freedom per mate: Rz rotation about, Tz translation along, its Z axis. |
name | string | Feature name (default "Relation"). |
ratio | number | GEAR and LINEAR: the ratio between the mates (default 1). |
reverse | boolean | Reverse the direction of the coupling. |
onshape_get_mate_values Get mate values
Where every mate currently sits: each degree of freedom's value, translations in inches and rotations in degrees, keyed by unit (translationZ_in, rotationZ_deg).
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_set_mate_values Set mate values
Drive top-level mates to new positions — turn a revolute, slide a slider — and read them back; relations move the coupled mates too. Values are inches and degrees. Fails when Onshape does not apply a value, which it does silently for mates with limits enabled and for positions the rest of the assembly cannot reach.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
values * | array | One entry per mate, naming only the degrees of freedom to change. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_bom Get the bill of materials
The assembly's BOM table.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
indented | boolean | Return the indented BOM (default true). |
multi_level | boolean | Expand sub-assemblies (default false). |
onshape_assembly_mass_properties Get assembly mass properties
Mass, volume, centroid and inertia for a whole assembly.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_create_drawing Create a drawing
Create a drawing of a part, Part Studio or assembly. The source must be referenced by version — call onshape_create_version first and pass its id as src_version.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
name * | string | Drawing name. |
src_elem * | string | Element id being drawn. |
src_version * | string | Version id of the source element. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
part | string | Part id, to draw a single part. |
src_doc | string | Source document id (defaults to the target document). |
onshape_get_drawing_views List drawing views
The views placed on a drawing sheet.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_export_drawing Export a drawing
Export a drawing as PDF (or DWG/DXF) through the translation service.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
format | string | Format name: PDF, DWG, DXF (default PDF). |
out | string | Output file path (default onshape-drawing-<timestamp>.<format>). |
onshape_create_feature_studio Create a Feature Studio
Add a Feature Studio tab for custom FeatureScript.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
name * | string | Tab name. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_feature_studio Read a Feature Studio
The FeatureScript source of a Feature Studio.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_set_feature_studio Write a Feature Studio
Replace the FeatureScript source of a Feature Studio. The whole file is overwritten.
| Parameter | Type | Description |
|---|---|---|
contents * | string | The complete new FeatureScript source. |
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_feature_studio_specs Get Feature Studio specs
The feature specifications a Feature Studio defines, for calling its custom features.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
onshape_get_metadata Get element or part metadata
Read the properties of an element, or of one part when part is given.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
part | string | Part id, to read that part's properties. |
onshape_set_metadata Set element or part metadata
Write properties such as part number, description or material. Only editable properties are accepted; read onshape_get_metadata first to find the property ids.
| Parameter | Type | Description |
|---|---|---|
doc * | string | Document id — the <doc> in cad.onshape.com/documents/<doc>/w/<ws>/e/<elem>. |
elem * | string | Element id (tab) — the <elem> segment of the document URL. |
properties * | array | Property ids and their new values. |
ws * | string | Workspace id — the <ws> segment of the document URL. |
part | string | Part id, to set that part's properties instead of the element's. |
onshape_request Call any Onshape REST endpoint
Make an authenticated request to an arbitrary Onshape REST endpoint, for anything the dedicated tools do not cover. Paths start with /api/ and are documented at https://cad.onshape.com/glassworks/explorer. Prefer a dedicated tool when one exists — they normalise the response and validate the result.
| Parameter | Type | Description |
|---|---|---|
method * | string | HTTP method. |
path * | string | API path, e.g. /api/v6/documents/d/{did}/w/{wid}/elements. Must begin with /api/. |
body | JSON request body, for POST. | |
params | object | Query string parameters. |