Create, read, constrain and edit 2D SOLIDWORKS sketches by command
Parametric 2D sketching driven by data instead of mouse clicks. Create closed, constrained profiles (rectangles, circles, slots, polygons and cam lobes), read every segment and relation back as JSON, and edit dimensions, offsets, mirrors, patterns and trims with dry-run previews.
10 of the 92 verbs · Windows x64 · Late-bound SOLIDWORKS COM API
solid sketch --on PLANE|B64|datum:NAME|face:FEATURE[:PICK][:nx,ny,nz][:at=MM] --name N [--rect cx,cy,w,h[,r] ...] [--circle cx,cy,d ...] [--slot x1,y1,x2,y2,w ...] [--poly x,y;x,y;a:x,y,r[,1];... ...] [--lobe base,lift[,nose[,phase[,flank]]] ...] [--dim-names OLD=NEW,...] [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- One sketch named N on the active part with closed, related and dimensioned profiles
solid sketch-read --feature NAME [--full-ref] [--edit-view] [--file FILE] [--expect FILE] [--pid N]- Takes --feature NAME, the name of the sketch (no other option names it)
solid sketch-dim --feature SKETCH --name DIM --value V [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- Sets a dimension owned by one sketch of the active part
solid sketch-relation --feature SKETCH --type horizontal|vertical|parallel|perpendicular|coincident|tangent|equal|concentric|collinear [--segment NAME | --ref B64|@fN] [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- Adds one relation between segments of one sketch of the active part, each named by its sketch-segment name or a persistent reference/handle from sketch-read, never an index (horizontal and vertical take one segment, the others two)
solid sketch-offset --feature SKETCH [--segment NAME | --ref B64|@fN ...] --distance LEN [--both] [--reverse] [--no-chain] [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- Offsets segments of one sketch of the active part by LEN (metres, or with a suffix mm cm m in) with SketchOffset2, in the sketch edit mode, the segments named by sketch-segment name or persistent reference/handle from sketch-read, never an…
solid sketch-mirror --feature SKETCH [--segment NAME | --ref B64|@fN ...] [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- Mirrors segments of one sketch of the active part about another line of the same sketch
solid sketch-pattern --feature SKETCH [--segment NAME | --ref B64|@fN ...] --count N [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- Linear step and repeat of segments of one sketch of the active part (CreateLinearSketchStepAndRepeat): N instances (seed included, 2 to 1000) LEN apart (metres, or with a suffix mm cm m in) along a direction at angle A from the sketch X…
solid sketch-trim --feature SKETCH --at X,Y[,Z] [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- Trims one segment of one sketch of the active part at a pick point (SketchTrim, trim to the nearest intersections): the segment is selected as an object, AT is a point near the part to remove, in model coordinates
solid delete-relation --feature SKETCH [--segment NAME | --ref B64|@fN ...] [--point point:KIND(x,y) ...] [--type TYPE|CODE] [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- Deletes one relation of one sketch of the active part: the relation whose entities are exactly the named segments
solid delete-segment --feature SKETCH [--file FILE (open, writable)] [--expect FILE] [--pid N] [--confirm]- Deletes one segment of one sketch of the active part, selected as an object (a persistent ref or the name sketch-read reports, never a position): opens the sketch for edit, DeleteSelection2, closes it (rebuild)
Common questions
How do I create a fully dimensioned 2D sketch from the command line?
solid sketch creates a named sketch on a reference plane, datum or planar face with closed profiles (rectangles, circles, slots, polygons or cam lobes), geometric relations and named dimensions ready for solid extrude or solid cut.
Can I read and edit an existing SOLIDWORKS sketch?
Yes. solid sketch-read returns every segment, relation, dimension and handle as JSON; solid sketch-dim, solid sketch-relation, solid sketch-offset, solid sketch-mirror, solid sketch-pattern and solid sketch-trim modify sketches with dry-run previews.
Run these verbs on your own SOLIDWORKS models
Every verb above returns structured JSON and takes plain command-line flags. SolidWorks-CLI is local and on-premise: zero UAC elevation, zero SOLIDWORKS interop DLLs
redistributed, and every write is a dry run until you pass --apply. Fourteen-day free trial
with corporate e-mail, no card.
Other verb families
- Open, create, save and sandbox SOLIDWORKS files from the command line13 verbs
- Inspect SOLIDWORKS feature trees, dimensions, mass, holes and configurations15 verbs
- Build and edit 3D SOLIDWORKS part features, datums and materials17 verbs
- Automate SOLIDWORKS assemblies, mates, BOM and interference checks10 verbs
- Generate SOLIDWORKS drawings, section views, hole callouts and CAD exports7 verbs
- Validate, inspect and transactionally build SOLIDWORKS specs from JSON5 verbs
- Address SOLIDWORKS faces and edges by persistent reference and inspect COM APIs7 verbs
- Check SOLIDWORKS installations, ROT sessions, health, paths and batch runs8 verbs