edit_sketch
Modify an existing Onshape sketch by adding entities/constraints or removing ids, avoiding a full rebuild. Ideal for incremental edits like adding hole patterns or tightening constraints.
Instructions
Iterate on an existing sketch without rebuilding it. Pass any of addEntities, addConstraints, removeIds and the server fetches the current BTMSketch-151, splices the lists, and re-POSTs. Use this for the second/third pass on a sketch (adding a hole pattern after the outline lands; tightening a constraint after a regen check) instead of delete+recreate.
Add semantics are STRICT: every entity/constraint dict must carry a non-empty id string and ids may not collide with anything already on the wire. To retarget an id, removeIds it first and then addEntities it back.
removeIds is a single bag matched against entity ids AND constraint ids. Cascade: any constraint whose entities/entity (or sub-point ref like line1.start) names an entity in removeIds is auto-dropped and reported back in cascaded_removals so you see exactly what got pulled.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| elementId | Yes | Part Studio element ID | |
| removeIds | No | User ids to drop. Matches entities AND constraints. Constraints referencing a removed entity cascade out and are reported in cascaded_removals. | |
| documentId | Yes | Document ID | |
| addEntities | No | Entity dicts to append. Each must carry a unique `id` plus the type-specific fields the constraint-first sketch surface accepts. | |
| workspaceId | Yes | Workspace ID | |
| addConstraints | No | Constraint dicts to append. Each must carry a unique `id`. Reference entities by user-supplied `id` (e.g. `"entities": ["line1", "circle1"]`) or sub-points (`"line1.start"`). | |
| sketchFeatureId | Yes | featureId of the sketch to edit (from a prior create_sketch). |