SolidWorks

v0.2.0
io.github.NejcDvorsek/sw-mcp Checked 1 day ago Published 1 month ago

Model, measure and verify parametric parts and assemblies in a running SolidWorks (Windows).

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

get_status

Report whether SolidWorks is reachable, its revision, this server's version, and the active/current part.

new_document

Create a new empty part (kind='part') or assembly (kind='assembly'); it becomes the current document. Assemblies compose saved parts: insert_component places each part, add_mate constrains them, check_interference proves nothing overlaps. Drawings: drawing_file.

ParameterTypeDescription
kindstring

add_box

Add a rectangular block: sketch width x height on the first plane, extrude by depth. Dimensions are in millimetres. Returns the created feature name, the addressable depth dimension ('D1@<name>'), `dimensions` (width, height, depth; for set_dimension) and the resulting mass properties.

ParameterTypeDescription
depth_mm *number
height_mm *number
width_mm *number
namestring

add_extruded_profile

Extrude a closed polygon into a solid; it is auto-closed. - Default: points_mm = [[x,y], ...] on the first plane (same as add_box), extruded by depth_mm along +Z. rotate_deg turns the profile counterclockwise about about_mm ([x, y], the origin by default) first: draw a crank or a lug straight, then set it at its angle. spline=True runs a smooth closed spline through the points instead (organic shapes). - face='+z' (or '-x', ...): a boss grown out of ANY planar face; points_mm = [[x,y,z], ...] on that face (the face facing that way through them, as for add_hole)…

ParameterTypeDescription
depth_mm *number
points_mm *array
about_mm
corner_radii_mm
draft_degnumber
face
mergeboolean
name
plane
reverseboolean
rotate_degnumber
splineboolean

add_disc

Create a disc/puck/flange: a circle extruded along +Z, centred at (x_mm, y_mm). Flat faces are +Z/-Z, so add_hole and add_circular_pattern compose with it (round-flange bolt circles). The centre defaults to the origin; off it, its x and y are dimensions. Returns mass properties. Use new_document first.

ParameterTypeDescription
diameter_mm *number
thickness_mm *number
namestring
x_mmnumber
y_mmnumber

add_cylinder

Create a cylinder by revolving a profile 360° about an axis. The first revolve-based primitive. Returns the resulting mass properties (volume = π · r² · h). Use new_document first.

ParameterTypeDescription
diameter_mm *number
height_mm *number
namestring

add_cone

Create a cone/frustum by revolving a trapezoidal profile 360°. top_diameter_mm = 0 gives a full cone. Returns mass properties (volume = π·h/3 · (rb² + rb·rt + rt²)). Use new_document first.

ParameterTypeDescription
bottom_diameter_mm *number
height_mm *number
top_diameter_mm *number
namestring

add_revolved_profile

Revolve a closed profile on the Front plane about an axis in it. Without axis_mm: profile_mm = [[r, z], …] in mm, r = distance from the Y axis, z = position along it. With axis_mm = [[x1, y1], [x2, y2]]: profile_mm gives [x, y] points and the axis is the line through those two points, anywhere and at any angle (a hub turned about its own centre). Auto-closed and spun angle_deg (default 360°). Points on the axis give a solid (shafts, vases); a profile away from it gives a ring. The profile may not cross the axis. corner_radii_mm rounds corners as for add_extruded…

ParameterTypeDescription
profile_mm *array
angle_degnumber
axis_mm
corner_radii_mm
namestring

add_swept_pipe

Sweep a circular profile (pipe/tube/rod) along a 2D path on the Front plane. path_mm = [[x, y], …] in mm is the centreline. Interior corners are rounded with bend_radius_mm (required when the path turns; a 2-point straight path needs none); smooth=True runs a spline through the points instead, a flowing curve. diameter_mm = outer Ø; the round profile is auto-generated perpendicular to the path. Returns mass properties (pi r^2 x path_length_mm). Use new_document first.

ParameterTypeDescription
diameter_mm *number
path_mm *array
bend_radius_mmnumber
namestring
smoothboolean

add_swept_profile

Sweep an arbitrary closed PROFILE (cross-section) along a 2D PATH. profile_mm = [[u,v],…] in mm: the closed cross-section on the Right plane (u → world -Z, v → world +Y), centred near the origin. path_mm = [[x,y],…] in mm on the Front plane — MUST start at the origin heading +X (the profile is perpendicular to the path there). Path corners are rounded with bend_radius_mm; corner_radii_mm rounds the profile's corners as for add_extruded_profile. Volume = profile_area · path_length. For non-round extrusions along a path (rails, gaskets, trim, channels). Re…

ParameterTypeDescription
path_mm *array
profile_mm *array
bend_radius_mmnumber
corner_radii_mm
namestring

add_loft

Loft (blend) 2+ closed profiles, given one of two ways. - sketches=['Heel', 'Toe']: closed sketches by name (add_sketch on any planes), in order; cut=True cuts the lofted shape away (a straight bevel gear's tooth gap is a loft cut between heel and toe profiles). - profiles_mm + heights_mm: per profile a polygon [[x,y], ...] (mm) in Front-plane coords, or a round section {"center_mm": [x, y], "diameter_mm": d}, on parallel planes at heights_mm along +Z (same length, strictly increasing, starting at 0). A 2-profile loft is a ruled transition; 3+ blend smoot…

ParameterTypeDescription
cutboolean
heights_mm
name
profiles_mm
sketches

cut_profile

Cut a polygonal pocket, slot or window; the polygon is auto-closed. - Default: points_mm = [[x,y], ...] cut down from the +Z face. rotate_deg turns the profile about about_mm as for add_extruded_profile (notches at +/-60 degrees around a pivot). - face='+x' (or ...): points_mm = [[x,y,z], ...] on one face facing that way, found through them; for side pockets and cutouts. - plane='right' ('front' z = 0, 'top' y = 0, 'right' x = 0, or 'Plane1'): points_mm = 3D points ON that plane, cut symmetric about it. For shapes seen from the side: wedges, windows, symmetric…

ParameterTypeDescription
points_mm *array
about_mm
corner_radii_mm
depth_mm
face
keep_insideboolean
namestring
plane
rotate_degnumber

add_plane

Make a reference plane to sketch on: an offset or a turned plane, its position a dimension. base moved offset_mm along its normal (base: front/top/right or a plane by name), or a default plane turned angle_deg about a model axis it holds, about='x'/'y'/'z' (front holds x and y, top x and z, right y and z), by the right-hand rule. For both, turn first, then offset that plane. Or the plane through model point through=[x, y, z] square to normal=[dx, dy, dz] (any direction, e.g. square to a cone's generatrix). Returns its name for plane= arguments, and origin_mm, norma…

ParameterTypeDescription
about
angle_degnumber
basestring
name
normal
offset_mmnumber
through

list_bodies

List the part's solid bodies: name, volume and bounding box. A part holds several after merge=False or split_body; combine_bodies joins them again.

combine_bodies

Combine solid bodies of the part into `main` (a list_bodies name). operation 'add' joins the tools to main, 'subtract' cuts them out of it, 'common' keeps only what main shares with them. tools: body names, every other body by default. Returns mass properties and the bodies left.

ParameterTypeDescription
main *string
operation *string
namestring
tools

split_body

Split the part's body in two along a plane (front/top/right or a plane by name). The two bodies come back by name: combine them differently, or check each with list_bodies. Use add_plane first for a cut anywhere else.

ParameterTypeDescription
plane *string
namestring

add_thread

Cut a real, printable ISO metric thread (SolidWorks' own Thread feature). size: e.g. 'M10x1.5', 'M3x0.5', 'M10x1.0' -- checked against SolidWorks' thread profiles. (x_mm, y_mm, z_mm) = centre of the circular edge where the thread starts: the end face of a rod, or the mouth of a hole (internal=True). It runs length_mm into the material, right-handed. External: the rod must have the nominal diameter (M10 -> Ø10). Internal: drill the ISO basic minor diameter first, D - 1.0825*P (M10x1.5 -> Ø8.376). Returns mass properties and the thread's size, pitch and diameters.…

ParameterTypeDescription
length_mm *number
size *string
x_mm *number
y_mm *number
z_mm *number
internalboolean
namestring

add_rib

Add a straight stiffening rib / gusset in a plane parallel to the Front plane. start_mm/end_mm = [x, y] ends of the rib's free edge (add_extruded_profile coordinates); the plane sits at height z_mm. The rib grows toward toward_mm (any [x, y] point on the side to fill, e.g. the inner corner of an L-bracket) until it meets the part, thickness_mm thick, centred on the plane. Returns mass properties: a triangular gusset with legs a and b adds a*b/2 * thickness.

ParameterTypeDescription
end_mm *array
start_mm *array
thickness_mm *number
toward_mm *array
z_mm *number
namestring

add_hole

Cut a round hole. Which one follows from the arguments: - diameter_mm at (x, y): straight through the thickness (the add_box extrude direction); coordinates share add_box's system (the centre of a 40x20 profile is x=20, y=10). - + face='+z' (or '-x', ...) and z_mm: on ANY planar face, centred at 3D point (x, y, z), the face facing that way through the point (a pocket floor or a step works too). Through all, or depth_mm deep (blind: heat-set inserts, screw pilots). Returns `dimensions` (diameter, x, y, depth). - + cbore_diameter_mm and cbore_depth_mm: a counterbor…

ParameterTypeDescription
x_mm *number
y_mm *number
cbore_depth_mm
cbore_diameter_mm
depth_mm
diameter_mm
face
fitstring
iso
name
size
threadstring
z_mm

add_boss_on_face

Grow a round boss (standoff, peg) height_mm out of ANY planar face, centred at (x, y, z) mm. The face is found as for add_hole with face=. For a PCB standoff, add a blind hole in its top. Returns mass properties and `dimensions`.

ParameterTypeDescription
diameter_mm *number
face *string
height_mm *number
x_mm *number
y_mm *number
z_mm *number
namestring

add_text_on_face

Engrave text into ANY planar face, or emboss it with emboss=True (labels, version numbers). (x, y, z) is the text's lower-left corner on the face; the text runs along the face sketch's horizontal axis: upright along +x on the top (+z) and front (-y) faces, turned on the others (vertical on +/-x, upside down on +y), so put labels on the top or front. height_mm is the character height, depth_mm the engraving depth or embossing height. The position is two dimensions ('x', 'y'); font must be installed (default: SolidWorks' own). Returns text_area_mm2, since letters hav…

ParameterTypeDescription
depth_mm *number
face *string
height_mm *number
text *string
x_mm *number
y_mm *number
z_mm *number
embossboolean
font
namestring

cut_offset_pocket

Pocket a planar face, leaving a rim rim_mm wide along its outline. The recessed web of an I-beam that follows a curved link, a tray, or a frame (depth_mm omitted: through all). The face is the one facing `face` ('+z', ...) through the point (x, y, z). The rim follows the outline, arcs and splines included; holes in the face stay holes. rim and depth come back as dimensions, and the pocket follows the outline when it changes. Returns mass properties.

ParameterTypeDescription
face *string
rim_mm *number
x_mm *number
y_mm *number
z_mm *number
depth_mm
namestring

cut_slot

Cut a straight slotted hole (obround) on the +Z face. Centred at (x_mm, y_mm); length_mm is centre-to-centre of the rounded ends, width_mm the slot width, angle_deg its orientation in the +Z plane (0 = +X). Cut blind by depth_mm or through when omitted. Returns mass properties.

ParameterTypeDescription
length_mm *number
width_mm *number
x_mm *number
y_mm *number
angle_degnumber
depth_mm
namestring

add_extruded_slot

Extrude a stadium (rounded tab, lug or link) from point start_mm to end_mm ([x, y] mm). The half-round ends are centred on the two points themselves; width_mm is the tab's width, depth_mm the extrusion along +Z. Volume = (width * length + pi * (width/2)^2) * depth. Returns mass properties.

ParameterTypeDescription
depth_mm *number
end_mm *array
start_mm *array
width_mm *number
namestring

extrude_sketch

Extrude an existing sketch of the current part by name, e.g. one a person drew. depth_mm along the sketch's normal (reverse=True: the other way), merged with the body. Or up_to='next': up to the next face of the part, ending on its shape (a post into a curved wall) and following it when it changes; or up_to='@x,y,z': up to the face through that point, also where 'next' fails (a side of the profile on a face: the refusal names a point ahead). The sketch keeps its own dimensions and relations, so the person's design stays in charge; read_sketch shows it first. Return…

ParameterTypeDescription
sketch *string
depth_mm
namestring
reverseboolean
up_to

add_sketch

Draw a sketch of lines, arcs and splines on a plane, fully defined, to extrude or cut. plane: "front", "top", "right" or a plane by name (add_plane). Points are [u, v] in the plane's own axes, which the result gives (origin_mm + u x_axis + v y_axis): front is (x, y), top (x, -z), right (-z, y). The outline starts at start_mm; each segment runs on from where the last ended: {"line": [u, v]}; {"arc": [u, v], "through": [u, v]} (an arc through a middle point); {"arc": [u, v], "tangent": true} (an arc flowing on from the segment before); {"spline": [[u, v], ..., [u, v]…

ParameterTypeDescription
plane *string
segments *array
start_mm *array
fixedboolean
name

cut_sketch

Cut an existing sketch of the current part by name into the body. depth_mm deep, or through all when depth_mm is omitted, against the sketch's normal: into the part from a face. From a plane with the part in front of it (a box on the Front plane) give reverse=True. Returns mass properties.

ParameterTypeDescription
sketch *string
depth_mm
namestring
reverseboolean

add_fillet

Round edges of the current part with one constant radius (mm). edges: "all" (default), "x"/"y"/"z" for edges parallel to that world axis, a face outline like "+z:outline" (the outer edges of the top face, not those of holes in it), every edge of one feature like "feature:Boss" (its top and where it meets the part: a moulded look), or explicit indices like "2,5" from list_edges. radii_at_mm = [[x, y, z, r], ...] makes the radius vary: r at the edge end at each point (list_edges gives the ends), radius_mm at the other ends, straight in between; 'vertex_radii' gives e…

ParameterTypeDescription
radius_mm *number
edgesstring
namestring
radii_at_mm
skip_shorter_mm
tangent_propagationboolean

add_full_round

Round a rib's top off completely: a full round fillet, as on a moulded part. The face facing `face` ("+z", ...) through the point (x, y, z) is the top; the two opposite flat side faces along it that lie closest together are the sides, so the round runs across the rib, not along it. The radius is half their distance (width_mm in the result) and follows the rib. Hand calculation: a rib w wide and L long loses L w^2 (1/2 - pi/8).

ParameterTypeDescription
face *string
x_mm *number
y_mm *number
z_mm *number
namestring

add_chamfer

Chamfer edges of the current part: distance_mm back along a face, at angle_deg (default 45°) to it. edges: "all" (default), "x"/"y"/"z", a face outline like "+z:outline", a feature's edges like "feature:Boss", or explicit indices like "2,5" from list_edges. Another angle than 45° needs from_face, which way the face that the distance runs along faces: "-z", angle_deg=60 makes an underside edge printable without support (round an arc the chamfer is a cone). Returns the number of edges chamfered and the mass properties.

ParameterTypeDescription
distance_mm *number
angle_degnumber
edgesstring
from_face
namestring

add_linear_pattern

Repeat a feature `count` times, `spacing_mm` apart, along a direction. direction: "+x"/"-x"/"+y"/... feature_name: the feature to repeat (e.g. "Hole"); defaults to the most recently added feature. Returns mass properties.

ParameterTypeDescription
count *integer
spacing_mm *number
directionstring
feature_name

add_circular_pattern

Repeat a feature `count` times evenly around 360° about an axis. The axis is the cylindrical face nearest (center_x_mm, center_y_mm) — e.g. a centre hole drilled there — or axis='y' (a model axis through the origin: revolved parts turn about y) or a reference axis by name (add_axis). feature_name defaults to the last feature. Bolt circle: drill a centre hole + one bolt hole, then pattern the bolt hole. angle_deg < 360 spreads the instances over that angle, first to last (with axis=).

ParameterTypeDescription
count *integer
angle_degnumber
axis
center_x_mm
center_y_mm
feature_name

add_axis

A reference axis anywhere: through=[[x, y, z], [dx, dy, dz]] (point and direction, model mm) or where two planes meet (planes=['Plane1', 'right']). Patterns turn about it by name (add_circular_pattern(axis=...)).

ParameterTypeDescription
name
planes
through

run_script

Run Python against the live SolidWorks: a whole part in one call, or what no tool covers; off when the server runs with --no-scripts. Give the script as code, or as a file at path: it may import helpers from its own folder (reloaded every run), so fix a part by editing the file and running it again. The script sees sw, model (current part/ assembly), drawing, mod (typed interfaces), wrap(obj, mod.IFeature), mm (mm -> m), to_mm, doubles([..]) (a VARIANT array) and session (this server's tools: session.new_part(), session.add_box(...)). print() is captured and `resul…

ParameterTypeDescription
code
image
path

add_mirror

Mirror features, or the whole body, about the 'front'/'top'/'right' plane moved offset_mm. Mirrors about z / y / x = offset_mm; plane may also name another plane in the part ('Plane1'), moved offset_mm along its normal. features: list_features names; the copies follow their seeds. Without features the body is mirrored and merged: model half of a symmetric part, mirror it about the face where the halves meet. The plane position comes back as dimension 'plane_offset'. Fails, leaving the part as it was, when a copy would land outside the part.

ParameterTypeDescription
plane *string
features
namestring
offset_mmnumber

add_shell

Hollow the current part to a wall of thickness_mm, opening one face. open_face: a direction "+z"/"-z"/"+x"/... removes that planar face (open shell); "none" makes a closed hollow. Returns the resulting mass properties.

ParameterTypeDescription
thickness_mm *number
open_facestring

add_base_flange

Start a sheet metal part: a flat tab from a closed profile, or a bent section from an open one. profile_mm: [[x, y], ...] on the Front plane, closed when the last point is the first (a tab, thickness_mm thick along +z); open (an L, U or Z section, corners bent with bend_radius_mm inside) extruded depth_mm along +z. sketch: a sketch of the part by name instead (add_sketch: arcs, other planes). The thickness of an open profile lies on its right walked from the start (flip_thickness: left); reverse: along -z. k_factor sets the flat length. Returns the sheet's thicknes…

ParameterTypeDescription
bend_radius_mm *number
thickness_mm *number
depth_mm
flip_thicknessboolean
k_factornumber
namestring
profile_mm
reverseboolean
sketch

add_edge_flange

Bend a flange up from a straight edge of a sheet metal part, the edge's whole length. at_mm: a model point [x, y, z] on the edge (list_edges). length_mm is the flange's outside length, from the outer corner of the bend; angle_deg the bend. It rises the way the face at the edge looks (from an edge of the top face of a tab: up); flip=True folds it the other way. position: 'material_inside' (the part keeps its outer size), 'material_outside' or 'bend_outside'. bend_radius_mm defaults to the sheet's. Returns dimensions 'length' and 'angle' for set_dimension.

ParameterTypeDescription
at_mm *array
length_mm *number
angle_degnumber
bend_radius_mm
flipboolean
namestring
positionstring

flat_pattern

A sheet metal part's flat pattern: action 'info' (thickness, bend radius, K-factor, number of bends, flat blank size), 'flatten' / 'fold' (show the part flat or bent), or 'export' to path (.dxf or .dwg: the flat outline and bend lines for laser cutting; save the part first).

ParameterTypeDescription
actionstring
path

add_closed_corner

Close the open corner between two flanges of a sheet metal part, ready to weld. at_mm: a model point [x, y, z] on the end face of one flange at the corner (list_faces); that flange grows to meet the one beside it. kind 'overlap' (it runs over the other flange's end), 'underlap' (it stops behind it) or 'butt'; gap_mm stays between them. The flat pattern keeps the extra material. Mark the corner's weld on the drawing with add_symbol(type='weld').

ParameterTypeDescription
at_mm *array
gap_mmnumber
kindstring
namestring

add_weld_bead

A fillet weld bead where two bodies meet: a plate on a base (merge=False), a member on a plate. from_mm / to_mm: model points [x, y, z] on the two faces, of two bodies (one body cannot be welded to itself). size_mm: the leg. side 'one' (along the from face where the faces meet), 'both' (both sides of it) or 'all_around'. length_mm + pitch_mm make it intermittent (staggered with side='both'). Shows in the model and drawings, adds no mass. Returns the weld's length (its beads' sum) for a hand check.

ParameterTypeDescription
from_mm *array
size_mm *number
to_mm *array
length_mm
namestring
pitch_mm
sidestring
staggeredboolean

add_structural_member

Weldment frame members of a library profile along the lines of a path. profile / size as SolidWorks' weldment profile library names them, e.g. standard 'iso': 'square tube' '20 x 20 x 2' / '30 x 30 x 2.6' / '40 x 40 x 4', 'rectangular tube' '50 x 30 x 2.6', 'pipe' '26.9 x 3.2', 'angle iron' '25 x 25 x 4', 'c channel' '80 x 8', 'sb beam' '100 x 8' (a wrong name lists what there is). path_mm: [[x, y], ...] on plane, lines in a chain (closed when the last point is the first); or sketch by name. The profile is centred on the lines; corner 'miter', 'butt1', 'butt2' or N…

ParameterTypeDescription
profile *string
size *string
corner
name
path_mm
planestring
rotate_degnumber
sketch
standardstring

add_end_cap

Close the open end of a tube or pipe member with a plate. at_mm: a model point on the end face (the tube wall's end). thickness_mm outward past the end (inward=True: into the tube); its edge inset_mm in from the tube's outside (default half the wall); chamfer_mm on its corners.

ParameterTypeDescription
at_mm *array
thickness_mm *number
chamfer_mm
inset_mm
inwardboolean
namestring

add_gusset

A gusset plate in the corner of two weldment members. first_mm / second_mm: model points on the two faces, at right angles. leg1_mm runs along the first, leg2_mm along the second. shape 'triangle' (area leg1 leg2 / 2), or 'polygon' with both tips cut square end_mm long. position 'center' / 'start' / 'end' along the corner; thickness_side 'both' (centred), 'inner' or 'outer'.

ParameterTypeDescription
first_mm *array
leg1_mm *number
leg2_mm *number
second_mm *array
thickness_mm *number
end_mm
namestring
positionstring
shapestring
thickness_sidestring

cut_list

A weldment's cut list: each kind of member with its description, length (outside, mitres included), end angles and quantity; and the weld beads with their size and length, and the total weld length.

set_dimension

Set a named driving dimension (e.g. 'D1@BlockExtrude') in mm, rebuild, and remeasure. This is the parametric edit at the heart of the correction loop. Every modelling tool returns its dimensions by role in `dimensions`. An angle (a revolve, an angle mate) takes degrees; list_dimensions shows the unit. A point's coordinate from the origin (a sketch's 'x3', 'y2') takes a sign, -5 being across the origin; any other length is a size, refused below 0. A value SolidWorks does not take (a dimension an equation drives, a size of 0) is refused with the reason, and the part…

ParameterTypeDescription
dimension_name *string
value_mm *number

slice_mesh

Cross-sections of an STL/3MF mesh at the given heights along axis 'x'/'y'/'z'. For modelling a part that must fit something that only exists as a mesh. Returns each section's closed loops, largest first, as polygon points (mm) ready to use as profiles. frame (3MF): 'object' (the mesh's own frame) or 'build' (as placed on the slicer's plate).

ParameterTypeDescription
axis *string
heights_mm *array
path *string
framestring

compare_with_mesh

Compare the current part's cross-sections with a reference mesh's at the same heights. offset_mm [dx, dy, dz] moves the mesh into the part's frame. A different area means a misread feature; equal areas with different extents a shifted frame. Returns per-section pairs and the worst differences.

ParameterTypeDescription
axis *string
heights_mm *array
path *string
framestring
offset_mm

list_dimensions

List every dimension in the current part: name (for set_dimension), feature, value, unit. For a part opened from disk, or when the names the tools returned are gone.

read_sketch

Read a sketch of the current part back, e.g. one a person drew (a list_features name). Gives its lines, arcs, circles and splines in MODEL coordinates (mm), construction geometry marked, its dimensions (for set_dimension) and whether it is fully defined: check a design against fixed points before building on it with extrude_sketch / cut_sketch.

ParameterTypeDescription
name *string

list_features

List the current part's modelling history in tree order: name, type, suppressed. For a part opened from disk, or to find the step to undo. Flags features that fail to rebuild and names sketches that are not fully defined.

delete_feature

Delete a feature (a list_features name) with its sketch, then rebuild and remeasure. The way to undo a step. Refuses when other features are built on it and names them, and what is built on those; with_children=True deletes them all. dry_run=True only lists what would go (would_delete). Equations that named its dimensions break and come back as broken_equations; with_equations=True deletes them (global variables stay).

ParameterTypeDescription
name *string
dry_runboolean
with_childrenboolean
with_equationsboolean

suppress_feature

Suppress a feature, or bring it back with suppress=False; rebuild and remeasure. Keeps the feature and its dimensions, unlike delete_feature, so it suits trying a variant. Features that depend on it follow both ways.

ParameterTypeDescription
name *string
suppressboolean

reorder_feature

Move a feature (a list_features name), with its sketch, to just before another one; rebuild and remeasure. For a boss added last that filled holes cut earlier: build it at the end as usual, then move it before the first of those cuts, and they cut through it again. Refused, the part as it was, when the feature is built on something at or after that place. Returns the new order (features) and the features that fail to rebuild (failing_features).

ParameterTypeDescription
before *string
name *string

set_appearance

Colour and/or see-through of the current part, or of one component in an assembly. rgb: [r, g, b], 0..255 each; transparency: 0 solid .. 1 clear (0 makes a see-through component solid again). In an assembly, component names it ('Bracket-1', 'Leg-1/Thigh-1'); the colour then belongs to the assembly and the part keeps its own. What is left out stays as it was.

ParameterTypeDescription
component
rgb
transparency

set_material

Assign a material by name (e.g. "6061 Alloy", "AISI 1020", "ABS"). Makes mass and density reflect a real material instead of the 1000 kg/m³ default. One SolidWorks does not have (say "TPU") comes with its density: density_kg_m3=1210 makes it, by that name, carrying only the density. The English names work on a SolidWorks in another language too. Returns mass properties including density.

ParameterTypeDescription
name *string
databasestring
density_kg_m3

set_equation

Add an equation, or replace the one that sets the same name; rebuild and remeasure. A SolidWorks equation string, e.g. '"D1@BlockExtrude" = 25' or '"D1@BlockExtrude" = 2 * "D1@Sketch1"'. A global variable is '"W" = 40'; link a dimension to it with '"width@Sketch1" = "W"', and set '"W" = 45' again to change it. Persists a relation (unlike set_dimension). A list of equations is set in order with one rebuild at the end (later ones may use earlier ones), and a refused one undoes the whole list. Returns the index (per equation for a list), whether it replaced one, the f…

ParameterTypeDescription
equation *

list_equations

List the equations and global variables: index, equation, name it sets, value, global. `broken` marks an equation that names a dimension or variable that is gone, as one left behind by delete_feature; delete_equation removes it. automatic_solve_order False means SolidWorks solves them as listed: one above the line that sets its variable then warns and lags a rebuild. Any set_equation turns it on.

delete_equation

Delete an equation by the name it sets ("L_thigh", "D1@Boss") or its list_equations index. Rebuilds and returns what was deleted, failing_features and mass properties.

ParameterTypeDescription
equation *string

list_documents

List the documents open in SolidWorks: title, path (empty until saved), type, unsaved changes. `current` marks the one the tools work on, `active` SolidWorks' own. Parts an open assembly loaded come along, with visible false.

activate_document

Make an open document current again by its title, also a new one that was never saved. For after open_document / close_document on another document; list_documents gives the titles.

ParameterTypeDescription
title *string

delete_mate

Delete a mate of the current assembly by name (list_components, or add_mate's 'mate'). A list of names deletes them all at once, with one rebuild. Their components are free to move again. Returns what was deleted and how many mates are left (list_components lists them).

ParameterTypeDescription
name *

suppress_mate

Suppress a mate so it stops holding its components (it stays in the tree), or bring it back. suppress=False brings it back. Returns whether it is suppressed now.

ParameterTypeDescription
name *string
suppressboolean

delete_component

Remove a component from the current assembly, with the mates that hold it. component: its name in list_components ("Bracket-1", or "Bracket" while there is one). Returns the mates deleted, how many components are left and the assembly's mass properties.

ParameterTypeDescription
component *string

replace_component

Swap a top-level component for another .sldprt or .sldasm, in the same place. SolidWorks re-attaches each mate to the new part's matching face where it can. Returns the new component, the mates kept, and the mates that broke or went: each with its type, the other components, and what it held on the old part (the face's type, normal or axis and centre in the component's own frame), plus up to three candidate faces on the new part ('#index', nearest first). Re-mate with delete_mate and add_mate(mates=[...]).

ParameterTypeDescription
component *string
path *string

rebuild

Force a rebuild of the current part or assembly and report whether it rebuilt without errors. In an assembly, mate_errors names each mate SolidWorks flags, and each mate that lost a face or edge it used (it rebuilds fine, but holds nothing).

ParameterTypeDescription
top_onlyboolean

get_mass_properties

Get volume (mm^3), mass (kg), surface area (mm^2), centre of mass, and bounding box.

get_bounding_box

Get the bounding box (min/max/size in mm) of the current part, tight, or of the whole assembly.

list_faces

List the part's faces (index, planar?, normal, area, centre) for inspection. A cylindrical face also gives its axis, radius and a point on the axis (for a hole: its centre), so hole patterns can be read off. component: a component of the current assembly, listed in its own frame (e.g. an imported servo); for a sub-assembly, every part's faces in the sub-assembly's frame, each naming its part. A part's indices shift as features are added; a component's are ordered by part, type, centre and area, so they stay while its shape does. add_mate takes them as '#5'.

ParameterTypeDescription
component

list_edges

List the part's edges: index, type, length, ends; lines also axis and midpoint. Narrow it on a big part: face (a list_faces index, "#5"), feature (the edges of the faces it made), within_mm ([[x1, y1, z1], [x2, y2, z2]]: both ends inside), min_length_mm. Indices are always those of the whole part: use them with add_fillet/add_chamfer edges="2,5".

ParameterTypeDescription
face
feature
min_length_mm
within_mm

check_printability

Check the current part for 3D printing, built along `up` ('+z', '-y', ...). Overhangs: downward faces leaning more than overhang_deg from vertical (90 = a flat ceiling) need support; the faces on the bed do not count. Gives the overhanging area per face (list_faces index) with its worst lean and centre, the bed contact area and the print height. With min_wall_mm (e.g. two nozzle widths) also the walls thinner than that, measured straight through the material from points spread over every face, with where each is thinnest. A spot right beside an edge where faces mee…

ParameterTypeDescription
min_wall_mm
overhang_degnumber
upstring

read_model

Read everything a design review needs of the current part in one read-only call (schema sw-mcp/model@1). Sections ('core' is always read; None reads core, material, holes, radii and setups, plus walls with wall_mm and draft with pull): - core: mass, volume, area, density, centre of mass, bbox, bodies, features with rebuild errors, dimensions with their own tolerance (type, plus/minus, ISO fit such as 'H7'), equations, under-defined sketches. - material: name, database, density; null if none is assigned. - holes: every hole of every body, identical ones grouped…

ParameterTypeDescription
clearance_pairs
pull
sections
wall_mm

export

Export the current part or assembly to STEP/STL/IGES/Parasolid/3MF (format from extension). Silent (no prompts). Verifies the file appears on disk and reports its size. For STL/3MF, tessellation resolution is set first: quality 'coarse'|'fine' (default 'fine' for print quality), or pass deviation_mm (+ optional angle_deg) for a reproducible custom resolution (overrides quality). Ignored for other formats. An assembly goes to STL as one file, or one file per component with per_component=True (SolidWorks names them); `files` lists what was written. STL/3MF keep the p…

ParameterTypeDescription
path *string
angle_deg
deviation_mm
file_format
per_componentboolean
qualitystring

screenshot

Save a screenshot of the current part or assembly (PNG/JPG/TIF). view: 'iso' (default), 'front', 'back', 'left', 'right', 'top' or 'bottom'; or from_dir = [x, y, z], the direction to look from, e.g. [-1, 1, -1] to see from behind and below what iso hides (the model's +y stays up). Zoomed to fit, or onto a detail: zoom_mm = [[x1, y1, z1], [x2, y2, z2]], the corners of the region to fill the image (model mm, in any view). Reference planes and axes are left out, so they do not cut through the shape; show_planes=True keeps them.

ParameterTypeDescription
path *string
from_dir
show_planesboolean
viewstring
zoom_mm

make_drawing

Make a manufacturing drawing of the current part in one call: PDF, .slddrw, DXF or DWG. Front, top and side views (first angle) plus an iso view on an ISO sheet ('A4' upright, 'A3'..'A0' landscape) with SolidWorks' ISO title block, at the largest standard scale that leaves room for dimensions (or scale='1:2'). The model's dimensions come in once each, one hole callout per set of identical Hole Wizard holes ('4X ...'), their centres dimensioned, and the title block shows material and mass. A sheet metal part gets its flat pattern in place of the iso view, with bend…

ParameterTypeDescription
path *string
keep_openboolean
max_sheet
scale
sheetstring

build_drawing

Build a drawing from scratch from a spec; edit the spec and rebuild to fine-tune. spec: {"part": path (default the current part), "sheet": "A3", "scale": "1:2", "views": [{"name": "front", "orient": "front", "at": [x, y]}, {"name": "side", "projected_from": "front", "side": "right"}, {"name": "A-A", "section_of": "front", "through": [x, y, z], "normal": "x"}, {"name": "B", "detail_of": "front", "center": [x, y, z], "radius": 5}, {"name": "flat", "flat_pattern": true, "right_of": "front"}], "import": ["model", "callouts", "hole_locations"], "dims": [{"view": "fr…

ParameterTypeDescription
spec *object
path

drawing_file

The current drawing's document: action 'new' (sheet 'A4' upright or 'A3'..'A0', part: the saved model its views show, default the current part), 'open' (path .slddrw), 'save' (path .slddrw), 'export' (path: PDF, DXF, DWG, PNG/JPG/TIF of the sheet) or 'close' (without saving). The drawing is kept apart from the current part. 'new' returns the frame, title block and free areas in sheet mm.

ParameterTypeDescription
action *string
part
path
sheetstring

set_drawing_properties

Fill the title block through the custom properties its fields show. description, material, weight, finish go to the part ('from part' links material / weight to the part's own, so they follow the model); drawn_by, drawn_date, checked_by, checked_date, approved_by, revision, company, part_no, qty or any other name go to the drawing. Returns what each title block field now shows and which properties it has no field for.

ParameterTypeDescription
properties *object

add_view

Add a view. kind: - 'model': orientation 'front', 'top', 'right', 'left', 'back', 'bottom', 'iso' or '*Name'; its geometry centred on at=[x, y] (sheet mm), or beside='<view>' on side 'right'/'left'/'above'/'below'; - 'projected': from parent, on side (first angle), aligned with it; - 'section': parent cut by the plane through model point through=[x, y, z] square to model axis normal ('x'/'y'/'z'); label 'A'; flip=True looks the other way; - 'detail': of parent, the circle round model point center=[x, y, z] with model radius radius_mm, at scale (default about 2…

ParameterTypeDescription
at
beside
center
flipboolean
gap_mm
kindstring
label
name
normalstring
orientationstring
parent
part
radius_mm
scale
side
through

edit_view

Move a view (its geometry centred on at=[x, y], or beside='<view>' on side, gap_mm apart; align 'center' or 'start'), change it (scale '1:2' or 'sheet'; display 'hidden_removed', 'hidden_visible', 'wireframe', 'shaded', 'shaded_edges'; tangent_edges; new_name), or delete=True it. Projected and section views stay aligned with their parent, so they only move along that line.

ParameterTypeDescription
name *string
alignstring
at
beside
deleteboolean
display
gap_mm
new_name
scale
side
tangent_edges

list_views

The sheet's frame and title block, and each view (or one): name, type, scale, outline and geometry box (sheet mm), the model-to-sheet mapping (a model point p lands at origin + p.x * x + p.y * y + p.z * z), and its annotations: id, type, shown text, value, box.

ParameterTypeDescription
view

import_dimensions

Bring in what the model already knows. kinds: 'model' (its dimensions, each once), 'callouts' (one counted hole callout per set of identical Hole Wizard holes, '4X ...'), 'hole_locations' (their centres dimensioned from the left and bottom edges), 'center_marks' (centre marks and lines). Default the first three, into every view (or one).

ParameterTypeDescription
kinds
view

add_dimension

Dimension in a view between references, or the size of one. ref / to: 'edge:-x' (the face facing -x, seen edge-on), 'hole:CBore1' (its centre; alone its diameter), 'feature:CornerFillet' (alone: its radius), or a model point [x, y, z] (the edge nearest it). style 'single' (ref to `to`), or 'baseline' / 'chain' / 'ordinate' with to=[ref, ref, ...] measured from ref. direction 'auto', 'horizontal', 'vertical', 'aligned'. side 'below', 'above', 'left', 'right' (default nearer the geometry); offset_mm from the outline (default the first free row: 10, 18, 26 ...). Retur…

ParameterTypeDescription
ref *
view *string
directionstring
offset_mm
side
stylestring
to

add_symbol

A symbol on an edge of a view, its leader attached mid-edge. type: - 'hole_callout': ref 'hole:<feature>'; diameter, depth, counterbore/countersink, thread, linked to the model; count=True counts identical holes in the view into it ('4X ...'); - 'surface_finish': ISO 1302, roughness 'Ra 1.6', process 'machined', 'any' or 'no_removal'; - 'datum': lettered datum feature symbol, label 'A'; - 'gtol': ISO 1101 frame, symbol straightness, flatness, circularity, cylindricity, line_profile, surface_profile, parallelism, perpendicularity, angularity, position, concentricity,…

ParameterTypeDescription
ref *
type *string
view *string
at
countboolean
datums
diameterboolean
label
material_condition
processstring
roughness
symbol
tolerance
weld

add_note

A note on the sheet; at=[x, y] its top-left corner (sheet mm), by default above the title block. Lines: '\n'.

ParameterTypeDescription
text *string
at
height_mmnumber

add_table

A table on the sheet: rows [[cell, ...], ...] (title=True merges the first row), or gear={...} for a computed gear data table: kind 'spur' (diameters, span over k teeth, centre distance) or 'bevel' (straight: cone angles, cone distance, chordal thickness and height, crown to apex), teeth, module, mating_teeth, pressure_angle_deg, face_width_mm, profile_shift, shaft_angle_deg, accuracy, extra_rows [[label, value], ...]; teeth, module and mating_teeth default to the part's custom properties Teeth, Module, MatingTeeth. cut_list=True: the weldment's cut list (item, quantity,…

ParameterTypeDescription
at
column_widths_mm
cut_listboolean
gear
rows
text_height_mmnumber
titleboolean

edit_annotation

Change an annotation by id ('RD3@Drawing View1'), or delete=True it. prefix / suffix (a prefix replaces SolidWorks' own symbol: a radius needs 'R', e.g. '4X R'), precision (decimals), tolerance [upper, lower] mm, fit ('H7'), a note's text, its place at=[x, y] (sheet mm), diametric=True. A model dimension keeps these in the part (the result says changes_part).

ParameterTypeDescription
annotation_id *string
at
deleteboolean
diametric
fit
precision
prefix
suffix
text
tolerance

auto_layout

Lay all views out again: the main view top left, its projected and section views beside it, the rest in the room left, with room for dimensions, at the largest standard scale that fits (or scale); then, if anything still reaches off the frame, onto the title block or into another view, each view moves with its annotations as one footprint (the notes and tables too) to clear it. arrange_dimensions=True then lets SolidWorks space each view's dimensions evenly.

ParameterTypeDescription
arrange_dimensionsboolean
main
scale

check_drawing

Problems on the sheet, to fix before sending the drawing out. Views or annotations outside the frame or over the title block, views overlapping, texts overlapping or on view geometry, crossing leaders, text under 2.5 mm, probable duplicate dimensions, and hole/cut/fillet/chamfer features no dimension or callout covers.

render_drawing

Picture (PNG/JPG) of the sheet, or of the region zoom_mm = [[x1, y1], [x2, y2]] (sheet mm), to look at it.

ParameterTypeDescription
path *string
zoom_mm

close_document

Close one open document by its title (list_documents): a part, assembly or drawing. Two files of one name from different folders share a title: give the path of the one you mean instead. Without a title it closes the current part or assembly. save=True saves it over its own file first; otherwise closing never asks and unsaved changes are lost (the result says discarded_changes). Parts that an open assembly loaded (visible false) close with that assembly and are refused here. With no title and no current document it closes SolidWorks' active one, but only when that…

ParameterTypeDescription
saveboolean
title

save_document

Save the current part (.sldprt) or assembly (.sldasm) to path, or over its own file without one. Saves silently and checks the file was really written. Drawings: drawing_file(action='save').

ParameterTypeDescription
path

open_document

Open a .sldprt or .sldasm, or import a STEP/IGES/Parasolid file; it becomes the current document. A neutral file opens as a part, or as an assembly if it holds one (kind='part' / 'assembly' says which up front). A part shows its history in list_features and its dimensions in list_dimensions; an imported body has no history, but the tools work on it (holes and pockets on its faces, bosses, fillets), and the result gives its solid body count and mass properties. An imported assembly's parts arrive as components at their places, ready for list_components and add_mate;…

ParameterTypeDescription
path *string
kind

insert_component

Insert a .sldprt, or a .sldasm as a sub-assembly, with its ORIGIN at (x, y, z) mm. The part's own origin lands exactly on that point, and the placement is read back and verified. fixed=True pins the component; fixed=False leaves it free for mates. The default fixes only the FIRST component, giving the assembly a ground to build against. Returns the component's name, placement and box.

ParameterTypeDescription
path *string
fixed
x_mmnumber
y_mmnumber
z_mmnumber

list_components

List the assembly's components (name, path, fixed, position, rotation, bounding box) and mates. Positions are in mm and rotations in degrees, both in assembly coordinates; the bounding box of each component is in assembly coordinates too. Each mate gives its name, SolidWorks type, the components it holds, the dimension of a distance or angle mate, and an error when SolidWorks flags it. On a big assembly, narrow it: name keeps the matching components ('Bolt*' as a wildcard, 'bolt' anywhere in the name) and the mates holding them; mates=False leaves the mates out; br…

ParameterTypeDescription
briefboolean
matesboolean
name

set_component_transform

Move/rotate a component: its origin to (x, y, z) mm, rotated rx/ry/rz degrees. name is the component name ('Bed' or 'Bed-1'); rotations apply X, then Y, then Z about the assembly axes, and work on a fixed component too. The transform is read back and compared, so a move SolidWorks ignored (e.g. one already pinned by mates) fails loudly instead of silently leaving the part where it was.

ParameterTypeDescription
name *string
x_mm *number
y_mm *number
z_mm *number
rx_degnumber
ry_degnumber
rz_degnumber

add_mate

Mate a face of one component to a face of another, or add several mates in one call. comp_a/comp_b are component names ('Bed' or 'Bed-1'; 'Leg-1/Thigh-1' inside a sub-assembly). face_a/face_b select a face in that component's OWN frame: by direction "+x"/"-x"/"+y"/... (optionally "+y:inner" for the cavity side of a hollow part), by its list_faces(component=...) index, "#5", or by a point on it, "@x,y,z" (a hole's wall: its centre plus the radius along x). mate_type between planar faces: "coincident", "distance" (distance_mm), "parallel", "perpendicular" or "ang…

ParameterTypeDescription
angle_degnumber
comp_a
comp_b
distance_mmnumber
face_a
face_b
flipboolean
mate_typestring
mates
stop_on_errorboolean

check_interference

Report component pairs whose solids overlap, with the volume in mm^3. Touching faces do not count (a bed standing on the floor is fine); only real overlapping material does. count == 0 means the assembly is clash-free.

measure_distance

The smallest distance (mm) from a component to another one, a point or an axis. Give component_b; or point_mm = [x, y, z] in assembly mm, and the nearest point on the component comes back too, with inside: true when the point lies in its material; or axis_mm = [[x, y, z], [dx, dy, dz]], the endless line through that point along that direction, such as a bolt's axis. 0 means they touch or overlap; check_interference tells which. Sub-assemblies count with all their parts; one part inside is 'Leg-1/Thigh-1'.

ParameterTypeDescription
component_a *string
axis_mm
component_b
point_mm

check_motion

Step a joint through its range and check the assembly at every step. dimension_name: an angle or distance mate's dimension (add_mate returns it); values in degrees for an angle, mm for a distance, e.g. [30, 60, 90, 120, 150]. Each step gives the overlapping pairs with their volume and the distance between each pair in distances ([["Rod", "Bolt"], ...]); the summary gives clash_free and each pair's smallest distance with the value where it occurs. The dimension goes back to its value afterwards. A joint inside a sub-assembly is 'D1@Angle1@Leg-1'. Refused while a mat…

ParameterTypeDescription
dimension_name *string
values *array
distances

swept_region

Outline what a component covers in a plane while a joint moves, to keep clear of it or cut it away. Steps the joint's dimension through values (as check_motion, e.g. every 5 degrees over 30..150), cuts the component at axis = each of heights_mm (a few heights inside a layer, not on its faces) and joins all of it, made margin_mm wider, within about tolerance_mm. frame: the component to give the coordinates in, such as the part to cut from; else the assembly's. Each region's outline runs counter-clockwise in the plane's other two axes, (x, y) across z: give it to…

ParameterTypeDescription
component *string
dimension *string
heights_mm *array
values *array
axisstring
frame
margin_mmnumber
tolerance_mmnumber