SolidWorks

io.github.hjbaard由 GitHub 账号 hjbaard 发布v0.20.0更新于 Nov 14, 2026

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

已验证STDIO仅桌面开发者工具媒体与设计

概览

AI 生成的概览

让 AI 助手在运行中的 Windows SolidWorks 里建模、测量并校验参数化零件与装配体,每一步都用实测几何核对。

可以做什么
  • 创建与修改零件:基本体、拉伸轮廓、旋转、扫掠、放样、样条、参考平面、多实体、孔、螺纹、筋、型腔、槽、圆角、倒角、抽壳、阵列、镜像与文字
  • 驱动与检查模型:设置尺寸和方程式,列出特征、尺寸、面与边,读取草图,删除或压缩特征,重建,获取质量属性与包围盒
  • 处理已有零件:按名称拉伸或切除他人绘制的草图,导入 STEP,导出 STEP/STL/IGES/Parasolid/3MF 并截图
  • 装配与校验:插入和变换零部件,添加与压缩配合,按行程步进关节,检查干涉与距离,测量装配体边界
  • 面向制造验证:可打印性检查、网格切片与比对、带尺寸的工程图
适用场景
当你希望助手真正设计或修改 SolidWorks 几何、并用数值证明结果时使用。适合参数化零件设计、3D 打印准备、装配配合与干涉检查,以及从网格逆向重建零件。
运行要求
Windows,已安装并授权 SolidWorks,且 SolidWorks 必须处于运行状态(服务器连接当前实例,不会自行启动)。需要 Python 3.11+,通过 uv/uvx 运行。需将 Y-up 零件模板设为默认模板;仅在 SolidWorks 2026 上测试,旧版本未验证。未声明任何 API 密钥或环境变量。
安装前请注意
它会写入你正在使用的 SolidWorks 会话:工具会创建、修改、删除和压缩特征与零部件,并向你指定的路径导出或保存文件。请在重要文档的副本上操作,并注意 0.x 早期版本的工具名称与约定仍可能变化。长时间会话会增大 SolidWorks 内存占用,出现警告时应保存并重启。

安装

在 SourceWeft 中

  1. 打开 控制台中的 SolidWorks,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

SolidWorks MCP

[PyPI] [License: MIT]

Let an AI agent (Claude, or any other MCP client) model real parametric parts and assemblies in your own SolidWorks — and check its own work. Every modelling call returns the measured volume, mass and bounding box, so the agent can compare the result with the spec and correct itself instead of guessing that it "looks about right".

[3D-print mounting bracket with counterbored holes, bolt circle and cable slot] [M10 bolt with a real, printable ISO metric thread] [Revolved and shelled vase]

[Swept pipe with rounded bends] [Lofted and shelled horn]

Built by the tools themselves: a mounting bracket (every step checked against a hand calculation), an M10 bolt with a real thread, a revolved + shelled vase, a swept pipe, a lofted + shelled horn.

Why this server

  • It verifies, not just generates. Features report measured geometry; dimensions and mates are measured back after the rebuild.
  • Fully defined sketches. Every sketch is constrained the way a designer would: dimensions from the origin, relations only where the geometry is exactly horizontal, vertical or on the origin. Tools return their dimensions by role (width@Sketch1), so the part stays editable, in SolidWorks or through the agent.
  • Real CAD, not just primitives. Extrude, revolve, sweep, loft and splines; holes, counterbores, slots and pockets on any face; rounded polygon corners; ISO holes from the Hole Wizard; real ISO metric threads; fillets, chamfers, shells, patterns, mirrors, ribs, equations and materials. Assemblies with mates and interference checks. STEP/STL/3MF export and screenshots. Engraved and embossed text. Work on existing parts: list, delete, suppress and reorder features; read, extrude and cut a person's sketches; import STEP. Colours per part or component. Joints with concentric and angle mates, checked over their range. Printability checks and dimensioned drawings. Planes at any offset or angle. Several bodies per part, combined and split. Variable fillets and full rounds. Free sketches with tangent arcs and splines. 88 tools in total.
  • It fails loud. A call that cannot do what was asked returns {ok: false, error} with the cause, never silently wrong geometry.
  • A fixed, typed tool surface. There is no "run arbitrary code" tool; the agent can only do what the tools allow.
  • Tested against real SolidWorks. 754 tests; each feature's integration test compares the result with a hand calculation.
  • Local. It talks to your running SolidWorks over COM; the server itself makes no network calls.

Quickstart

  1. Install uv.

  2. Start SolidWorks and leave it open (the server attaches to the running instance — it does not launch one).

  3. Register the server with your MCP client.

    Claude Code:

    bash
    claude mcp add solidworks -- uvx solidworks-mcp

    Claude Desktop (claude_desktop_config.json) or any other client:

    json
    {  "mcpServers": {    "solidworks": {      "command": "uvx",      "args": ["solidworks-mcp"]    }  }}

    It is also listed in the official MCP Registry as io.github.hjbaard/solidworks-mcp.

  4. Ask for a part, for example:

    Design a 100 × 80 × 8 mm mounting plate with a Ø16 mm centre bore, four counterbored M5 holes 12 mm from the corners and R5 corners. Check the volume against your own calculation, then export a fine STL.

Guidelines for agents

The server hands every MCP client short modelling guidelines when it connects (conventions, verify each step, known pitfalls). The full guide is the resource solidworks://guide: recipes for holes, ribs, threads and assemblies, 3D-print advice, and how to reverse-engineer a part from a mesh (STL/3MF). The same text is in src/solidworks_mcp/guide.md.

Requirements and compatibility

  • Windows, with SolidWorks installed, licensed and running.

  • Python 3.11+ (uv fetches one if needed).

  • A Y-up part template, SolidWorks' standard. Since SOLIDWORKS 2025 new parts can also be Z-up; the tools build in the Y-up frame and refuse a Z-up part with a message that says so. Choosing Y-up in the New Document dialog is not used for parts made through the API: make a Y-up part, save it as a .prtdot, and set that file as the part template under Tools > Options > System Options > Default Templates.

  • Tested on SOLIDWORKS 2026 (3DEXPERIENCE R2026x). The API calls it uses exist since SOLIDWORKS 2020 SP2, so 2020–2025 should work, but that is untested. To check your installation, run this with SolidWorks open:

    bash
    uvx solidworks-mcp --selftest

    It builds a few small parts, compares each with a hand calculation and closes them unsaved. Please paste its output in a compatibility report, whether it worked or not.

Status: early (0.x). It works end-to-end, but tool names and conventions may still change. See CHANGELOG.md.

Troubleshooting

  • Start with the selftest: uvx solidworks-mcp --selftest shows your SolidWorks release, language and templates, and which tool areas work. Add its output to a bug report.
  • "No running SolidWorks found" / connection fails — SolidWorks must be running before you start the server or run a script; it attaches to the active instance via GetActiveObject and does not launch one.
  • First call is slow or EnsureModule errors — the first COM call generates the makepy typelib wrappers under your temp gen_py folder. Let it finish; if it gets into a bad state, delete the gen_py cache and retry. Early binding is mandatory on this build (see Architecture).
  • A feature returns {ok: false, error: ...} — that is by design: every tool fails loud with a readable message rather than silently producing wrong geometry. Read the message; it names the likely cause.
  • Only tested against SOLIDWORKS 2026 (3DEXPERIENCE R2026x). On other builds the verified enum values or method signatures may differ — re-run scripts/introspect_api.py to inspect your installed typelib.

Development

Clone the repository, then install it editable into a venv:

powershell
python -m venv .venv.\.venv\Scripts\python.exe -m pip install -e .[dev]

To run the MCP server from this checkout instead of via uvx, point your client at the venv's Python:

json
{  "mcpServers": {    "solidworks": {      "command": "C:\\path\\to\\SolidWorks-MCP\\.venv\\Scripts\\python.exe",      "args": ["-m", "solidworks_mcp.server"]    }  }}

Run the verification scripts

With SolidWorks open:

powershell
.\.venv\Scripts\python.exe scripts\probe_connection.py     # M0.\.venv\Scripts\python.exe scripts\m1_block.py             # M1.\.venv\Scripts\python.exe scripts\m2_parametric.py        # M2.\.venv\Scripts\python.exe scripts\test_mcp_server.py      # M3 (full MCP loop over stdio).\.venv\Scripts\python.exe scripts\m5_demo_bracket.py      # M5 (3D-print bracket, every step verified)

scripts/introspect_api.py regenerates/inspects the installed typelib and prints verified enum values — run it if SolidWorks is upgraded and signatures change.

Tests

powershell
.\.venv\Scripts\python.exe -m pytest                 # all tests.\.venv\Scripts\python.exe -m pytest -m "not solidworks"   # fast unit layer, no SolidWorks

Two layers: pure unit tests (units, selector/direction parsing, polygon cleaning, the component-placement maths, and that every MCP tool forwards its arguments to the right session method) run anywhere; integration tests (solidworks marker) drive a running SolidWorks and verify each feature's volume — or each component's placement — against a hand calc. They auto-skip if SolidWorks isn't reachable.

Tools

The server speaks MCP over stdio.

Part tools

ToolPurpose
get_statusIs SolidWorks reachable? revision, server version, active/current part
new_partCreate a new empty part (becomes current)
add_box(width_mm, height_mm, depth_mm, name)Sketch rectangle + extrude; returns mass properties
add_cylinder(diameter_mm, height_mm, name)Cylinder by revolving a profile 360° about an axis (Y axis)
add_disc(diameter_mm, thickness_mm, name, x_mm, y_mm)Disc/puck/flange: circle extruded along +Z, centred at (x, y) (holes/patterns compose)
add_cone(bottom_diameter_mm, top_diameter_mm, height_mm, name)Cone/frustum by revolve (top Ø = 0 → full cone)
add_revolved_profile(profile_mm, angle_deg, name, corner_radii_mm, axis_mm)Revolve any closed (radius, height) profile about the Y axis (shafts, vases, rings), or [x, y] points about any line axis_mm on the Front plane; corner_radii_mm rounds its edges
add_swept_pipe(path_mm, diameter_mm, bend_radius_mm, name, smooth)Sweep a round profile along a 2D path with rounded bends (pipes, tubes, rods), or along a spline through the points with smooth=True
add_swept_profile(profile_mm, path_mm, bend_radius_mm, name, corner_radii_mm)Sweep any closed cross-section along a 2D path (rails, gaskets, trim, channels); corner_radii_mm rounds the cross-section
add_lofted_solid(profiles_mm, heights_mm, name)Loft/blend 2+ polygon or round profiles on stacked parallel planes (transitions, adapters, a leg thick at the knee)
loft_sketches(sketches, name)Loft through 2+ closed sketches on any planes, in order, so a loft runs in any direction
add_rib(start_mm, end_mm, toward_mm, thickness_mm, z_mm, name)Straight rib / gusset in a plane parallel to Front at z_mm, grown toward toward_mm until it meets the part (L-bracket gussets)
add_extruded_profile(points_mm, depth_mm, name, corner_radii_mm, rotate_deg, about_mm, draft_deg, merge)Extrude any closed polygon [[x,y],…] (brackets, sections); corner_radii_mm rounds its corners with real sketch fillets, each radius a dimension; rotate_deg turns it about a pivot; draft_deg tapers its walls; merge=False keeps a separate body
add_plane(base, offset_mm, angle_deg, about, name)A reference plane offset from a plane, or turned about a model axis; its offset or angle a dimension; gives its origin and axes
add_extruded_profile_on_plane(points_mm, plane, depth_mm, reverse, name, corner_radii_mm, draft_deg, merge)Extrude a polygon drawn on any plane (3D points on it), merged with the part
list_bodies()The part's solid bodies: name, volume, bounding box
combine_bodies(operation, main, tools, name)Add, subtract or intersect bodies of the part (add / subtract / common)
split_body(plane, name)Split the part into two bodies along a plane
add_extruded_spline(points_mm, depth_mm, name)Extrude a smooth closed spline through points (free-form/organic outlines)
add_hole(diameter_mm, x_mm, y_mm, name)Cut a circular through-hole at (x, y) through the depth axis
add_counterbore_hole(clearance_diameter_mm, cbore_diameter_mm, cbore_depth_mm, x_mm, y_mm, name)Counterbored screw hole (flush cap-head / heat-set insert) on +Z
add_thread(size, x_mm, y_mm, z_mm, length_mm, internal, name)Real, printable ISO metric thread (e.g. M10x1.5) from a rod's end edge or a hole's mouth, via SolidWorks' Thread feature; the size is checked against the thread profiles. Internal: drill the basic minor diameter first (M10x1.5 → Ø8.376)
add_hole_on_face(diameter_mm, face, x_mm, y_mm, z_mm, depth_mm, name)Round hole on ANY planar face at a 3D point, through or blind (side holes, heat-set insert holes); the face through the point is used
add_hole_wizard(kind, size, face, x_mm, y_mm, z_mm, depth_mm, fit, thread, name)ISO hole from SolidWorks' Hole Wizard tables: clearance (ISO 273 fits), counterbore, countersink or tapped; thread="modeled" cuts a real, printable thread
add_boss_on_face(diameter_mm, face, x_mm, y_mm, z_mm, height_mm, name)Round boss (standoff, peg) grown out of ANY planar face
add_extruded_profile_on_face(points_mm, face, depth_mm, name, corner_radii_mm)Polygon pad/ledge grown out of ANY planar face (3D points on the face)
add_text_on_face(text, face, x_mm, y_mm, z_mm, height_mm, depth_mm, emboss, font, name)Engrave text into ANY planar face, or emboss it: labels, version numbers; the position is two dimensions
cut_profile(points_mm, depth_mm, name, corner_radii_mm, rotate_deg, about_mm)Cut a polygon pocket/slot from the +Z face (blind or through), optionally turned about a pivot
cut_profile_on_face(points_mm, face, depth_mm, name, corner_radii_mm)Cut a polygon pocket on ANY face (3D points on the face)
cut_profile_through_plane(points_mm, plane, depth_mm, name, corner_radii_mm)Cut a polygon drawn on the Front/Top/Right plane or a plane by name, through all both ways or depth_mm centred on the plane (wedges, side windows, symmetric recesses); keep_inside keeps the profile instead, so two views make a 3D shape
cut_offset_pocket(face, x_mm, y_mm, z_mm, rim_mm, depth_mm, name)Pocket a face leaving a rim along its outline (I-beam web, tray, frame); rim and depth are dimensions
cut_slot(length_mm, width_mm, x_mm, y_mm, angle_deg, depth_mm, name)Cut a straight slotted hole (obround) on the +Z face at any angle
add_extruded_slot(start_mm, end_mm, width_mm, depth_mm, name)Extrude a stadium (rounded tab, lug, link) between two points, the round ends centred on them
add_fillet(radius_mm, edges, name, radii_at_mm, skip_shorter_mm)Round edges (edges: all, axis x/y/z, a face outline "+z:outline", one feature's edges "feature:Boss", or indices "2,5"); radii_at_mm varies the radius from end to end; a refusal names the edges that do not fit
add_full_round(face, x_mm, y_mm, z_mm, name)Round a rib's top off completely between its two closest opposite sides
add_chamfer(distance_mm, edges, name)Chamfer edges at 45° (edges: all, axis, a face outline, a feature's edges, or indices)
add_shell(thickness_mm, open_face)Hollow to a wall thickness; open a face (+z/…, #5), several (["+z", "#5"]) or none
add_linear_pattern(count, spacing_mm, direction, feature_name)Repeat a feature N times along +x/-x/…
add_circular_pattern(count, center_x_mm, center_y_mm, feature_name)Repeat a feature N times around an axis (bolt circle)
add_mirror(plane, offset_mm, features, name)Mirror features (copies follow their seeds) or the whole body about the Front/Top/Right plane, or a plane by name, moved offset_mm; fails when a copy would land outside the part
set_dimension(dimension_name, value_mm)Change a named driving dim (e.g. D1@BlockExtrude, or any name a tool returned in dimensions), rebuild, remeasure; an angle in degrees
set_equation(equation)Add a global equation or variable linking dims (e.g. "W" = 40, then "width@Sketch1" = "W"), or replace the one that sets the same name; names the features that fail to rebuild
set_equations(equations)Add or replace a list of equations with one rebuild
list_equations / delete_equation(equation)List the equations (value, global, broken) / delete one by name or index
slice_mesh(path, axis, heights_mm, frame)Cross-sections of an STL/3MF mesh as polygon loops, ready to use as profiles; needs no SolidWorks
compare_with_mesh(path, axis, heights_mm, frame, offset_mm)Compare the part's cross-sections with a reference mesh (area and extent differences)
read_sketch(name)A sketch read back in model coordinates: lines, arcs, circles, splines, its dimensions, fully defined or not
add_sketch(plane, start_mm, segments, name)Sketch an outline of lines, arcs and splines on any plane, fully defined: tangent where it flows, dimensioned from the origin
extrude_sketch(sketch, depth_mm, reverse, name, up_to) / cut_sketch(sketch, depth_mm, reverse, name)Build on an existing sketch by name (one a person drew): extrude it blind or up to the next face, or cut it blind or through all
list_dimensions(contains)Every dimension in the part, or those whose name or feature holds contains: name (for set_dimension), feature, value, unit
list_features()The part's history in tree order (name, type, suppressed); flags features that fail to rebuild and sketches that are not fully defined
delete_feature(name, with_children, with_equations)Undo a step: delete a feature with its sketch; refuses (and names them) while other features depend on it, unless with_children; names the equations it breaks, or deletes them with with_equations
suppress_feature(name, suppress)Take a feature out but keep it and its dimensions (try a variant); suppress=False brings it back with its dependents
set_material(name, database, density_kg_m3)Assign a material (e.g. 6061 Alloy) so mass/density are real; one SolidWorks lacks (e.g. TPU) comes with its density
rebuild(top_only)Force rebuild, report errors
get_mass_propertiesVolume, mass, density, surface area, centre of mass, bounding box
get_bounding_boxTight part bounding box (min/max/size, mm)
list_faces(component) / list_edges(face, feature, within_mm, min_length_mm)Inspect faces (normal/area/centre; a cylinder's axis, radius and centre, also of a component in an assembly) and edges (type/length/ends/axis) by index, narrowed to a face, a feature, a box or a length
check_printability(up, overhang_deg, min_wall_mm)For a print direction: overhanging faces (area, worst lean, centre), islands and edge stretches that start in the air, bed contact, height; with min_wall_mm the walls thinner than that
export(path, file_format, quality, deviation_mm, angle_deg, per_component)STEP/STL/IGES/Parasolid/3MF (silent; verifies file). STL/3MF tessellation: quality coarse/fine, or explicit deviation_mm+angle_deg; an assembly's STL as one file or one per component
screenshot(path, view, zoom_mm, show_planes, from_dir)PNG/JPG/TIF from a standard view (iso, front, top, …) or any direction, zoomed to fit or onto a region; planes and axes left out unless asked for
make_drawing(path)2D drawing as PDF or editable .slddrw: front, top, right (first angle) and isometric views on A4 with the model's own dimensions, each once
save_part(path) / open_part(path)Save to / open a native .sldprt; open_part also imports STEP, IGES and Parasolid files as a part to build on
close_part(save)Close the current part or assembly; without one, SolidWorks' active document if it is saved
list_documents / activate_document(title)The open documents (path, type, unsaved changes) / make one current again, also one never saved

Assembly tools

ToolPurpose
new_assemblyCreate a new empty assembly (becomes the current document)
open_assembly(path) / save_assembly(path)Open / save a native .sldasm; open_assembly also imports STEP, IGES and Parasolid assemblies, parts as components in place
insert_component(path, x_mm, y_mm, z_mm, fixed)Insert a part, or a .sldasm as a sub-assembly, with its origin at (x, y, z); the first component is fixed by default
list_componentsName, path, fixed, position, rotation and bounding box of every component (its own extent, also when turned), and the mates with their dimensions and errors
delete_component(component)Remove a component from the assembly, with its mates
replace_component(name, path, reattach_mates)Put another file in a component's place, keeping its position and, where they find their faces, its mates
set_component_transform(name, x_mm, y_mm, z_mm, rx_deg, ry_deg, rz_deg)Move/rotate a component; the transform is read back and verified
add_mate(comp_a, face_a, comp_b, face_b, mate_type, distance_mm, angle_deg, flip)Mate two faces (by direction, or #index from list_faces): coincident, distance, parallel, perpendicular, angle, or concentric between cylinders — measured back afterwards; a refused mate is removed. A distance or angle mate returns its dimension: a joint angle as one number
check_motion(dimension_name, values, distances)Step a joint through its range: overlapping pairs and chosen distances per step, the smallest distance and where it occurs, the components that moved
swept_region(component, dimension, values, heights_mm, axis, margin_mm, tolerance_mm, frame)What a component covers in a plane over a joint's range: its outline, with a margin, in the coordinates of the part to cut from
delete_mate(name) / suppress_mate(name, suppress)Delete a mate, or suppress it (and bring it back)
check_interferenceComponent pairs whose solids overlap, with the volume in mm³ (touching faces don't count)
measure_distance(component_a, component_b, point_mm, axis_mm)Smallest distance between two components, to a point (with the nearest point, and whether the point is in the material), or to an axis
get_assembly_bounding_boxTight bounding box of the whole assembly (min/max/size, mm)

export and screenshot work on assemblies too.

Faces are selected by direction in the component's own frame (+x, -z, …), so a selector keeps meaning the same face however the component is turned. Add :inner (e.g. +y:inner) for the cavity side of a hollow part — the inside of a room wall instead of its outer skin.

All linear dimensions are millimetres; the server converts to/from the SolidWorks-internal metre/radian units at the boundary.

Architecture

src/solidworks_mcp/  binding.py     early-binding plumbing (wrap raw dispatches in generated classes)  com_worker.py  one dedicated STA thread; all COM calls serialised through it  session.py     SolidWorks operations (must run on the COM thread)  server.py      FastMCP tools that delegate to session via the worker  constants.py   enum values read from the installed typelib (verified)  units.py       mm<->m, deg<->rad  errors.py      SolidWorksError -> agent-facing {ok:false,error}

Two non-obvious design decisions, both load-bearing:

  1. Early binding is mandatory. On this build GetActiveObject returns a dispatch whose GetTypeInfo() fails, so EnsureDispatch/CastTo cannot infer types and pure late binding breaks (IModelDoc2.FirstFeature → DISP_E_MEMBERNOTFOUND). We generate makepy wrappers from the installed typelib and wrap each raw dispatch in the right interface class; calls then go by dispid via InvokeTypes, bypassing name resolution. See binding.py.

  2. A dedicated COM thread. COM is STA and thread-affine. The MCP server runs on asyncio, so all COM work is pinned to one worker thread (com_worker.py) that handlers post to and await — actively enforcing the "one COM session, single-threaded" rule that does not hold automatically in an async server.

Status and roadmap

Proven end-to-end against SOLIDWORKS 2026 (3DEXPERIENCE R2026x):

MilestoneWhat it provesState
M0COM connection to a running SolidWorks✅
M1new part → sketch rectangle → extrude → mass properties (volume matches hand calc)✅
M2change a named dimension → rebuild → volume changes predictably✅
M3full agent loop via the MCP server: build → measure → correct → export STEP/STL + screenshot✅
M4revolve, sweep, loft, profiles, holes/pockets/counterbores, slots, fillet/chamfer, shell, patterns, equations, materials, save/open🚧 ongoing
M5end-to-end 3D-print part: build a functional mounting bracket through the full loop → verify every dimension → export a fine STL (scripts/m5_demo_bracket.py)✅
M6assemblies: insert and position components, mate them, check interference — every placement and mate measured back (tests/test_assembly.py)✅

See Docs/PROGRESS.md for the detailed log and roadmap. Feedback and contributions are welcome.

Known limitations

  • Geometry so far: boxes, cylinders/cones (revolve), arbitrary extruded profiles, holes, polygon pockets/slots (cut_profile), fillets, chamfers, shells, linear + circular patterns (bolt circles); plus equations, materials, geometry inspection, and save/open of .sldprt, holes + pockets on any planar face (model→sketch transform), round flanges (disc + bore + bolt circle), and slotted holes (cut_slot, obround at any angle — the first arc-based sketch), general revolves (add_revolved_profile: any (r,z) profile → shafts, vases, rings), swept pipes/tubes (add_swept_pipe: a round profile along a rounded 2D path), and lofts (add_lofted_solid: blend stacked polygon profiles → transitions/adapters), free-form extrusions (add_extruded_spline: a smooth closed spline → organic/aesthetic outlines), and non-circular sweeps (add_swept_profile: any cross-section along a path → rails, gaskets, trim), and mirrors (add_mirror: features or the whole body about a plane through the part).
  • Selection: plane walk, face-by-normal/direction (_planar_face_by_normal, +z/…, with :inner for the cavity side of a hollow part), and edge selection by axis or explicit index (_select_edges). list_faces/list_edges let an agent inspect geometry before selecting.
  • Assemblies (M6): components, transforms, mates and interference detection. Component patterns, in-context features, configurations, drawings and Simulation (FEA) are out of scope.

来源:README.md,提交 58ca7bf

工具

88

get_status

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

无需输入参数。

new_part

Create a new empty part document; it becomes the current part.

无需输入参数。

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.

输入参数namedepth_mm必填width_mm必填height_mm必填

add_extruded_profile

Extrude a closed polygon into a solid: points_mm = [[x,y], ...] in mm. The polygon (first-plane coordinates, same as add_box) is auto-closed and extruded by depth_mm. Unlocks arbitrary prismatic shapes (brackets, profiles, polygons). corner_radii_mm rounds the corners with real sketch fillets: one radius for all, or one per vertex (0 = sharp); equal radii share one dimension ('radius', else 'r<i>'). 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. draft_deg tapers the walls inwards as they rise (negative: outwards), a dimension 'draft' (a moulded boss, a printable taper). merge=False keeps the result a separate body: list_bodies, combine_bodies. Returns mass properties (volume = polygon area * depth; a right-angled corner of radius r loses r^2 (1 - pi/4), a concave one gains it).

输入参数namemergeabout_mmdepth_mm必填draft_degpoints_mm必填rotate_degcorner_radii_mm

add_extruded_spline

Extrude a smooth CLOSED spline through points: points_mm = [[x,y], ...] in mm. Like add_extruded_profile but the outline is a smooth curve through the points (free-form/organic shapes: cams, rounded outlines, aesthetic bosses), auto-closed and extruded by depth_mm. A spline's area is not analytic, so the returned volume is the measured value. Returns mass properties. Use new_part first.

输入参数namedepth_mm必填points_mm必填

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_part first.

输入参数namex_mmy_mmdiameter_mm必填thickness_mm必填

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_part first.

输入参数nameheight_mm必填diameter_mm必填

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_part first.

输入参数nameheight_mm必填top_diameter_mm必填bottom_diameter_mm必填

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_profile (not those on the axis). Returns mass properties. Use new_part first.

输入参数nameaxis_mmangle_degprofile_mm必填corner_radii_mm

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_part first.

输入参数namesmoothpath_mm必填diameter_mm必填bend_radius_mm

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). Returns mass properties. Use new_part first.

输入参数namepath_mm必填profile_mm必填bend_radius_mmcorner_radii_mm

add_lofted_solid

Loft (blend) 2+ closed profiles on parallel planes stacked along +Z. profiles_mm: per profile a polygon [[x,y],…] (mm) in Front-plane coords, or a round section {"center_mm": [x, y], "diameter_mm": d} (thick at the knee, thin at the foot, centres free to wander). heights_mm = the +Z offset (mm) of each profile, same length, strictly increasing, starting at 0. A 2-profile loft is a ruled transition; 3+ blend smoothly. Each profile starts at its first vertex (a round one on +x): give polygons in a consistent vertex order to avoid twist. Returns mass properties. Use new_part first.

输入参数nameheights_mm必填profiles_mm必填

loft_sketches

Loft through 2+ closed sketches of the current part, by name, in order. The sketches may lie on any planes (add_plane, then add_sketch on it, or a person's sketches), so the loft runs in any direction, unlike add_lofted_solid's stack along +Z. Start each sketch at the matching corner (its first segment's start) to keep the loft from twisting. Returns mass properties.

输入参数namesketches必填

cut_profile_through_plane

Cut a polygon sketched on a reference plane, symmetric about that plane. plane: 'front' (z = 0), 'top' (y = 0), 'right' (x = 0) or the name of another plane in the part ('Plane1'); points_mm = 3D [x, y, z] points ON that plane (e.g. x = 0 for 'right'), or all [u, v] in the plane's own frame (as add_plane and add_sketch give it). Cuts through all in both directions (depth_mm omitted) or depth_mm in total, centred on the plane. For shapes seen from the side: wedges, windows, symmetric recesses. corner_radii_mm rounds the corners as for add_extruded_profile. keep_inside=True cuts away everything OUTSIDE the profile (through all): extrude the front view, cut the side view with keep_inside, and the part is the 3D shape both views agree on. Returns mass properties.

输入参数nameplane必填depth_mmpoints_mm必填keep_insidecorner_radii_mm

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. Returns its name for plane= arguments, and origin_mm, normal, x_axis and y_axis: a point (u, v) on it is origin + u x_axis + v y_axis.

输入参数basenameaboutangle_degoffset_mm

add_extruded_profile_on_plane

Extrude a polygon drawn on a reference plane, such as one add_plane made at an angle. points_mm = 3D [x, y, z] points ON the plane (origin + u x_axis + v y_axis from add_plane), or all [u, v] in that frame. depth_mm along the plane's normal, or the other way with reverse=True; merged with the part. corner_radii_mm, draft_deg and merge work as for add_extruded_profile. Returns mass properties.

输入参数namemergeplane必填reversedepth_mm必填draft_degpoints_mm必填corner_radii_mm

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.

输入参数main必填nametoolsoperation必填

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.

输入参数nameplane必填

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.

输入参数namesize必填x_mm必填y_mm必填z_mm必填internallength_mm必填

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.

输入参数namez_mm必填end_mm必填start_mm必填toward_mm必填thickness_mm必填

add_hole

Cut a circular through-hole at (x_mm, y_mm), through the part's depth axis. The hole runs straight through the thickness (the add_box extrude direction), perpendicular to the width x height profile face. Coordinates share add_box's system (the centre of a 40x20 profile is x=20, y=10). Returns mass properties.

输入参数namex_mm必填y_mm必填diameter_mm必填

add_counterbore_hole

Cut a counterbored screw hole on the +Z face at (x_mm, y_mm). A clearance shank through the thickness plus a larger coaxial flat-bottom pocket of cbore_depth_mm from the top — so a cap-head screw or heat-set insert sits flush/recessed (common for 3D-printed parts). cbore_diameter must exceed clearance_diameter. Coordinates share add_box's system. Returns mass properties.

输入参数namex_mm必填y_mm必填cbore_depth_mm必填cbore_diameter_mm必填clearance_diameter_mm必填

add_hole_on_face

Drill a round hole on ANY planar face, centred at 3D point (x, y, z) mm. face is "+x"/"-x"/"+y"/"-y"/"+z"/"-z": the face facing that way through the point is drilled, so a pocket floor or a step works too. Through all, or depth_mm deep (blind: heat-set inserts, screw pilots). Returns mass properties and `dimensions` (diameter, x, y, depth). from_edges=True measures x and y from the face's nearest straight edges instead of the origin, so the hole keeps its distance to them when the part changes (`measured_from` names the edges): use it where the design means it.

输入参数face必填namex_mm必填y_mm必填z_mm必填depth_mmfrom_edgesdiameter_mm必填

add_hole_wizard

An ISO hole from SolidWorks' Hole Wizard, sized by its standard tables. kind: 'clearance' (ISO 273), 'counterbore' (socket head cap screw), 'countersink' (socket countersunk screw) or 'tapped'; size e.g. 'M3'. Centred at (x, y, z) mm on the face through that point; through all, or depth_mm deep. fit: 'close' / 'normal' / 'loose'. For tapped holes thread='modeled' cuts a real, printable ISO thread instead of SolidWorks' cosmetic one. Returns the standard's sizes in `hole` and mass properties.

输入参数fitface必填kind必填namesize必填x_mm必填y_mm必填z_mm必填threaddepth_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_on_face. For a PCB standoff, add a blind hole in its top. from_edges works as for add_hole_on_face. Returns mass properties and `dimensions`.

输入参数face必填namex_mm必填y_mm必填z_mm必填height_mm必填from_edgesdiameter_mm必填

add_extruded_profile_on_face

Grow a polygon boss depth_mm out of ANY planar face: points_mm = [[x,y,z], ...] in mm. The 3D points lie on the face (found as for add_hole_on_face). For pads, ledges and mounting blocks on an existing part. corner_radii_mm rounds the corners as for add_extruded_profile. Returns mass properties.

输入参数face必填namedepth_mm必填points_mm必填corner_radii_mm

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 have no hand calculation.

输入参数face必填fontnametext必填x_mm必填y_mm必填z_mm必填embossdepth_mm必填height_mm必填

cut_profile

Cut a polygonal pocket/slot from the +Z face: points_mm = [[x,y], ...] in mm. Auto-closed polygon, cut blind by depth_mm or all the way through when depth_mm is omitted. For pockets, slots, cutouts. corner_radii_mm rounds the corners and rotate_deg turns the profile about about_mm, as for add_extruded_profile (notches at +/-60 degrees around a pivot). Returns mass properties.

输入参数nameabout_mmdepth_mmpoints_mm必填rotate_degcorner_radii_mm

cut_profile_on_face

Cut a polygon pocket/slot on ANY planar face: points_mm = [[x,y,z], ...] in mm. The 3D points must lie on one face facing `face` ("+x"/"-x"/...), which is found through them; cut blind by depth_mm or through when omitted. For side pockets/cutouts. corner_radii_mm rounds the corners as for add_extruded_profile. Returns mass properties.

输入参数face必填namedepth_mmpoints_mm必填corner_radii_mm

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.

输入参数face必填namex_mm必填y_mm必填z_mm必填rim_mm必填depth_mm

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.

输入参数namex_mm必填y_mm必填depth_mmwidth_mm必填angle_deglength_mm必填

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.

输入参数nameend_mm必填depth_mm必填start_mm必填width_mm必填

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. Returns mass properties.

输入参数nameup_tosketch必填reversedepth_mm

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]]} (through the points, ending at the last). "tangent": true on a line checks that it flows on. End on start_mm to close the outline. Segments that meet smoothly get a tangent relation, the rest is dimensioned from the origin: x<i>/y<i> for the i-th point given (points_mm lists them; start_mm is 0), r<k> for the radius of segment k. Then extrude_sketch / cut_sketch the returned sketch.

输入参数nameplane必填segments必填start_mm必填

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.

输入参数namesketch必填reversedepth_mm

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 each end's dimension. skip_shorter_mm leaves out edges shorter than that. tangent_propagation=True carries the round on along edges that run on smoothly from the given ones, as SolidWorks does by default: an edge ending where it runs into another tangentially, such as round a fillet, only rounds so. A refusal names the edges the radius does not fit (each tried alone, and with propagation). Returns the number of edges filleted and the mass properties.

输入参数nameedgesradius_mm必填radii_at_mmskip_shorter_mmtangent_propagation

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).

输入参数face必填namex_mm必填y_mm必填z_mm必填

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.

输入参数nameedgesangle_degfrom_facedistance_mm必填

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.

输入参数count必填directionspacing_mm必填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. feature_name defaults to the last feature. Bolt circle: drill a centre hole + one bolt hole, then pattern the bolt hole.

输入参数count必填center_x_mm必填center_y_mm必填feature_name

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.

输入参数nameplane必填featuresoffset_mm

add_shell

Hollow the current part to a wall of thickness_mm, opening one face or more. open_face: a direction "+z"/"-z"/"+x"/... removes that planar face (open shell), "#5" the face of that list_faces index, and a list ["+z", "#5"] opens several; "none" makes a closed hollow. Shell before cutting openings: a shell after them puts a wall along every cut edge. Returns the resulting mass properties.

输入参数open_facethickness_mm必填

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. The result's broken_features names the features that fail since the change (a later cut now off the part, a split whose bodies moved): fix or undo them first. 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 is left as it was.

输入参数value_mm必填dimension_name必填

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). Needs no SolidWorks.

输入参数axis必填path必填frameheights_mm必填

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.

输入参数axis必填path必填frameoffset_mmheights_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. contains (e.g. 'Sketch3' or 'Pad') keeps those whose name or feature holds that text; use it on a large part, whose full list is too long to read.

输入参数contains

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.

输入参数name必填

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).

输入参数name必填dry_runwith_childrenwith_equations

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.

输入参数name必填suppress

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. Reference planes and axes it is built on move along (moved_along); refused, the part as it was, when it is built on another feature at or after that place. Returns the new order (features) and the features that fail to rebuild (failing_features).

输入参数name必填before必填

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.

输入参数rgbcomponenttransparency

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.

输入参数name必填databasedensity_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). Returns the index, whether it replaced one, the features that fail to rebuild (failing_features) and mass properties.

输入参数equation必填

set_equations

Add or replace a list of equations at once, with one rebuild at the end. As set_equation for each, in order (later ones may use earlier ones). A refused equation undoes the whole list. Returns per equation its index and whether it replaced one, failing_features and mass properties.

输入参数equations必填

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.

输入参数equation必填

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_part / close_part on another document; list_documents gives the titles.

输入参数title必填

delete_mate

Delete a mate of the current assembly by name (list_components, or add_mate's 'mate'). Its components are free to move again. Returns the mates left.

输入参数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.

输入参数name必填suppress

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, the components left and the assembly's mass properties.

输入参数component必填

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).

输入参数top_only

get_mass_properties

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

无需输入参数。

get_bounding_box

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

无需输入参数。

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'.

输入参数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".

输入参数facefeaturewithin_mmmin_length_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. Islands: each place where the print starts in the air, its height above the bed, centre and faces; a downward edge between faces too steep to overhang still needs support there. Unsupported edges: stretches of such an edge with air below, also where the rest of it rests on material (the ends of a chamfered pad's edge beside a tube), with length, height, centre and faces. 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; that stops after a minute on a detailed part, and `rays` then says how much it measured. A spot right beside an edge where faces meet at a sharp angle reads as thin as the wedge of material there is: that is the edge, not a wall.

输入参数upmin_wall_mmoverhang_deg

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 part's or assembly's own coordinates (`frame`), also per component, so a mesh measures back where the model is; slicers place it anyway.

输入参数path必填qualityangle_degfile_formatdeviation_mmper_component

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.

输入参数path必填viewzoom_mmfrom_dirshow_planes

make_drawing

Make a 2D drawing of the current part: a PDF, or an editable .slddrw. Front, top and right views in European (first angle) projection plus an isometric view, on an A4 sheet at the scale SolidWorks picks, with the model's own dimensions, each shown once: a dimensioned sketch to print or send. Save the part first (save_part): the drawing refers to its file.

输入参数path必填

close_part

Close the current part or assembly without saving (export/save first if needed). With no current document it closes SolidWorks' active one, but only when that has no unsaved changes.

输入参数save

save_part

Save the current part to a native .sldprt file (so it can be reopened/edited).

输入参数path必填

open_part

Open a .sldprt, or import a STEP/IGES/Parasolid file as a new part; it becomes the current part. list_features shows its history, list_dimensions its dimensions. An imported body has no history, but the tools work on it (holes and pockets on its faces, bosses, fillets); an import returns its solid body count and mass properties. A file holding an assembly is refused, and an import over 30 MB unless allow_large=True (it can outlast the 2-minute call limit).

输入参数path必填allow_large

new_assembly

Create a new empty assembly document; it becomes the current document. Assemblies compose saved parts: insert_component places each part, add_mate constrains them, check_interference proves nothing overlaps.

无需输入参数。

open_assembly

Open a .sldasm, or import a STEP/IGES/Parasolid assembly; it becomes the current document. An imported assembly's parts arrive as components at their places, ready for list_components and add_mate; the result gives the component count. A file holding a single part is refused (use open_part), and an import over 30 MB unless allow_large=True (it can outlast the 2-minute call limit).

输入参数path必填allow_large

save_assembly

Save the current assembly to a native .sldasm file (so it can be reopened).

输入参数path必填

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.

输入参数path必填x_mmy_mmz_mmfixed

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 dimension of a distance or angle mate, and an error when SolidWorks flags it. A component that shows no geometry carries a `problem` (see replace_component).

无需输入参数。

replace_component

Put another part or assembly file in the place of a component of the current assembly. Keeps its position and, with reattach_mates, its mates where they still find their faces; `mate_errors` lists the ones that do not. Also the cure for a component that vanished after its part was made anew under the same path. Returns the new component (name, path, placement, bounding box).

输入参数name必填path必填reattach_mates

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.

输入参数name必填x_mm必填y_mm必填z_mm必填rx_degry_degrz_deg

add_mate

Mate a face of one component to a face of another. 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 "angle" (angle_deg between the faces' normals, 0..180); "concentric" between two cylindrical faces (a pin in a hole, a hinge axis), leaving the turn about the axis free. flip takes the other solution: the mirror side of a distance, the other turning direction of an angle. A distance or angle mate returns its `dimension`: drive it with set_dimension, or step it with check_motion. An angle mate's dimension then turns the joint the whole way round, past 180 and below 0 (-30 is 30 the other way, the same turn as 330). The result is measured back after the rebuild; a mate that does not hold is removed and the components are put back.

输入参数flipcomp_a必填comp_b必填face_a必填face_b必填angle_degmate_typedistance_mm

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'.

输入参数axis_mmpoint_mmcomponent_a必填component_b

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 mate is broken: the parts it should hold would drift and the result mean nothing.

输入参数values必填distancesdimension_name必填

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 add_sketch as a spline. count says how many separate regions there are.

输入参数axisframevalues必填component必填dimension必填margin_mmheights_mm必填tolerance_mm

get_assembly_bounding_box

Get the bounding box of the whole assembly (min/max/size in mm).

无需输入参数。

版本历史

19
  1. v0.20.0最新Nov 13, 2026
  2. v0.19.0Nov 3, 2026
  3. v0.17.0Oct 29, 2026
  4. v0.16.1Oct 15, 2026
  5. v0.16.0Oct 10, 2026
  6. v0.15.0Oct 9, 2026
  7. v0.14.0Oct 9, 2026
  8. v0.13.0Oct 6, 2026
  9. v0.12.0Oct 6, 2026
  10. v0.11.0Oct 5, 2026
  11. v0.10.0Oct 4, 2026
  12. v0.9.0Oct 3, 2026
  13. v0.8.0Oct 3, 2026
  14. v0.7.0Oct 2, 2026
  15. v0.6.0Oct 2, 2026
  16. v0.5.0Sep 27, 2026
  17. v0.4.0Sep 26, 2026
  18. v0.3.0Sep 25, 2026
  19. v0.2.1Sep 25, 2026

评分

已满足适用检查项的 90%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分
  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分