SolidWorks

io.github.NejcDvorsek由 GitHub 帳號 NejcDvorsek 發布v0.2.0更新於 Oct 31, 2026

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

已驗證STDIO僅桌面開發者工具媒體與設計

概覽

AI 產生的概覽

連接 Windows 上正在執行的 SolidWorks,讓助理建立、量測並驗證參數化零件、板金、銲件、組合件與工程圖。

可以做什麼
  • 建立與編輯零件:草圖、伸長、旋轉、掃掠、放樣、孔、螺紋、槽、肋、圓角、倒角、薄殼、陣列與鏡射
  • 檢查與量測:列出實體、面與邊,讀取質量屬性與尺寸,一次呼叫讀取整個模型以供審查
  • 板金與銲接:基材凸緣與邊線凸緣、匯出 DXF 的展開圖、閉合角、銲道、結構構件與切割清單
  • 組合件:插入並定位零組件、加入結合、檢查干涉並逐步驅動接頭運動
  • 工程圖與匯出:含視圖、尺寸與符號的圖紙,匯出 PDF、DXF 或 DWG,以及 STEP、STL、3MF 匯出與截圖
  • 在沒有專用工具涵蓋時,對目前工作階段執行自訂 Python 腳本
適用情境
適合已在 Windows 上使用 SolidWorks、希望助理逐步草擬、修改或檢查零件與組合件的情況,包括板金展開圖、銲件切割清單與工程圖。也適合需要每步與手算結果核對的反覆設計。
執行需求
需要 Windows 上已安裝並已開啟 SolidWorks(伺服器連接已開啟的工作階段,不會自行啟動);在 SOLIDWORKS 2026 上測試過,2020 及更新版本未測試。需安裝 uv 以便透過 uvx 執行 PyPI 套件。不需帳號、API 金鑰或網路存取。
安裝前請注意
run_script 會在你的電腦上執行任意 Python 程式碼,且預設開啟;可用 --no-scripts 啟動以關閉。相關工具會建立、修改與刪除目前文件中的特徵,可能影響尚未儲存的工作。目前為 0.x 早期版本,工具名稱可能變動。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 SolidWorks,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

sw-mcp

[PyPI] [License: MIT]

Let an AI agent (Claude, or any other MCP client) design parts, assemblies and drawings in your own SolidWorks, and check its own work as it goes. After every step it measures the result, so it can compare it with what you asked for and fix mistakes instead of guessing.

sw-mcp is a fork of SolidWorks-MCP by Henk Jan Baard and the SolidWorks connector of Jig. It works with any MCP client.

What it can do

  • Parts: sketches, extrudes, revolves, sweeps and lofts; holes, threads, slots and pockets on any face; fillets, chamfers, shells, ribs, patterns and mirrors. Every sketch is fully defined, so the part stays editable.
  • Checking: each step reports volume, mass and size; dimensions and mates are measured back. A step that can't be done fails with a clear reason instead of producing wrong geometry. read_model reads a whole part for a review in one call: holes with their sizes, internal radii, sharp inside corners, setups, thin walls and draft.
  • Sheet metal: base flanges (flat tabs or bent L, U and Z sections) and edge flanges with your thickness, bend radius and K-factor; the flat blank's size, and the flat pattern with bend lines exported to DXF for laser cutting. Closed corners, ready to weld.
  • Welds and weldments: weld beads between bodies, full or intermittent; frames of library tube, pipe, angle and channel profiles with mitred or butted corners, end caps and gussets; the cut list with each member's length and the total weld length.
  • Assemblies: insert and place components, mate them, swap parts, check interference and step joints through their range of motion.
  • Drawings: ISO sheets with a title block, views, sections and details, dimensions, hole callouts, surface finish and GD&T symbols, tables, and export to PDF, DXF or DWG. Sheet metal parts get their flat pattern with bend lines, bend notes and the blank's size; welded parts their weld symbols and cut list.
  • Your own parts: open existing parts and STEP files, change dimensions and equations, set materials, and build on sketches you drew.
  • 3D printing and export: STEP, STL and 3MF export, screenshots, printability checks, and comparing a part with a scanned mesh.

Get started

  1. Install uv.

  2. Start SolidWorks and leave it open.

  3. Add the server to your MCP client. In Claude Code:

    bash
    claude mcp add solidworks -- uvx sw-mcp
    Claude Desktop or another client
    json
    {  "mcpServers": {    "solidworks": {      "command": "uvx",      "args": ["sw-mcp"]    }  }}

    With Jig there is nothing to add: the plugin starts sw-mcp itself.

  4. Ask for a part:

    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. Then export an STL.

    Or a sheet metal one:

    Make a 2 mm steel tray, 80 × 50 mm, with 20 mm flanges on the long sides and an inner bend radius of 3 mm. Give me the flat pattern as a DXF and a drawing as a PDF.

    Or a welded frame:

    Weld a 600 × 400 mm frame of 30 × 30 × 2.6 square tube with mitred corners, cap the open ends, and give me the cut list and a drawing.

Requirements

  • Windows with SolidWorks installed and running. The server connects to the open SolidWorks; it doesn't start it.

  • Tested on SOLIDWORKS 2026. 2020 and newer should work but are untested.

  • To check your setup, run this with SolidWorks open. It builds a few small test parts and closes them without saving:

    bash
    uvx sw-mcp --selftest

Good to know

  • Early version (0.x): it works end to end, but tool names may still change. See the changelog.
  • Local: it talks only to the SolidWorks on your computer and makes no network calls.
  • Scripts are on by default: run_script runs any Python it's given on your computer. Start the server with --no-scripts to turn it off.
  • Multibody parts: face and edge tools only see the first body; read_model reads them all.

Help and feedback

Something not working? Open a bug report with the output of uvx sw-mcp --selftest. Running a SolidWorks version other than 2026? A compatibility report helps, whether it worked or not.

Credits and license

MIT, see LICENSE. The original server is by Henk Jan Baard (hjbaard/SolidWorks-MCP); this fork is maintained by Nejc Dvorsek.

來源:README.md,提交 2f349c1

工具

101

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.

輸入參數kind

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; 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). For pads, ledges, mounting blocks. - plane='Plane1' (add_plane, or 'front'/'top'/'right'): points_mm = 3D [x, y, z] points ON the plane (origin + u x_axis + v y_axis from add_plane); depth_mm along its normal, the other way with reverse=True. 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>'). 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. An argument that does not go with the variant is refused. 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).

輸入參數facenamemergeplanesplinereverseabout_mmdepth_mm必填draft_degpoints_mm必填rotate_degcorner_radii_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_document 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_document 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_document 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_document 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_document 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_document first.

輸入參數namepath_mm必填profile_mm必填bend_radius_mmcorner_radii_mm

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 smoothly. Each profile starts at its first vertex (a round one on +x). Give profiles in the same order and sense so they do not twist. Returns mass properties.

輸入參數cutnamesketchesheights_mmprofiles_mm

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 recesses. 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. Blind by depth_mm (with plane=: in total, centred on the plane), or through all when omitted. corner_radii_mm rounds the corners as for add_extruded_profile. Returns mass properties.

輸入參數facenameplaneabout_mmdepth_mmpoints_mm必填rotate_degkeep_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. 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, normal, x_axis and y_axis: a point (u, v) on it is origin + u x_axis + v y_axis.

輸入參數basenameaboutnormalthroughangle_degoffset_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 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 counterbored screw hole from the +Z face, a flat-bottom pocket over the clearance shank so a cap-head screw or heat-set insert sits flush. - iso='clearance' (ISO 273), 'counterbore' (socket head cap screw), 'countersink' (socket countersunk screw) or 'tapped', with size='M6', face and z_mm: SolidWorks' Hole Wizard, sized by the standard's tables and carried into drawing callouts. fit 'close' / 'normal' / 'loose'; thread='modeled' cuts a real, printable ISO thread in a tapped hole instead of the cosmetic one. Returns the standard's sizes in `hole`. Prefer iso= for standard fasteners. Returns mass properties.

輸入參數fitisofacenamesizex_mm必填y_mm必填z_mmthreaddepth_mmdiameter_mmcbore_depth_mm另有 1 個

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

輸入參數face必填namex_mm必填y_mm必填z_mm必填height_mm必填diameter_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_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. fixed=True freezes computed geometry (an involute, a cam) with Fix relations instead of dimensions.

輸入參數namefixedplane必填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 — 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=).

輸入參數axiscount必填angle_degcenter_x_mmcenter_y_mmfeature_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=...)).

輸入參數nameplanesthrough

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 `result = ...` comes back. All or nothing: a script that raises leaves the part as it was. One report comes back for a part: features_added, failing_features, bodies (volume, box), clashes between bodies, under_defined_sketches, mass properties, seconds, and image: one PNG of the iso, right, top and bottom views (for a path, next to the script; image='x.png' elsewhere).

輸入參數codepathimage

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. open_face: a direction "+z"/"-z"/"+x"/... removes that planar face (open shell); "none" makes a closed hollow. Returns the resulting mass properties.

輸入參數open_facethickness_mm必填

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 thickness, bend radius and K-factor.

輸入參數namesketchreversedepth_mmk_factorprofile_mmthickness_mm必填bend_radius_mm必填flip_thickness

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.

輸入參數flipnameat_mm必填positionangle_deglength_mm必填bend_radius_mm

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

輸入參數pathaction

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

輸入參數kindnameat_mm必填gap_mm

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.

輸入參數namesideto_mm必填from_mm必填size_mm必填pitch_mmlength_mmstaggered

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 None where they meet; rotate_deg turns it about the line. Several calls build a frame of several groups. Returns the cut list (cut_list).

輸入參數namesize必填planecornersketchpath_mmprofile必填standardrotate_deg

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.

輸入參數nameat_mm必填inwardinset_mmchamfer_mmthickness_mm必填

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

輸入參數nameshapeend_mmleg1_mm必填leg2_mm必填first_mm必填positionsecond_mm必填thickness_mm必填thickness_side

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

輸入參數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.

無需輸入參數。

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

輸入參數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). 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 features that fail to rebuild (failing_features) and mass properties.

輸入參數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.

輸入參數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_document / close_document 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'). 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).

輸入參數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, how many components are left and the assembly's mass properties.

輸入參數component必填

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=[...]).

輸入參數path必填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 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'.

輸入參數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. 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 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

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 with count and centres_mm (at the entrance). Hole Wizard holes give standard, size, fit and sizes from the wizard (source 'wizard'); other holes are measured from the geometry (source 'geometry'): kind simple / counterbore / countersink / tapped, diameter, depth, through, drilling axis, entrance. - radii: internal (concave) radii by feature, and sharp internal edges by feature, direction (x/y/z, null if curved) and length. - setups: planar face normals and the setup directions (+x ... or a vector). - walls (needs wall_mm): the thinnest wall and up to 20 spots below wall_mm. - draft (needs pull, '+z'...): each face's draft, the worst 20, and undercut faces. A section that fails is null and named in `gaps`, with anything cut off to keep the answer small. Nothing is selected, changed or saved. clearance_pairs belongs to the assembly section, not available yet.

輸入參數pullwall_mmsectionsclearance_pairs

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 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 lines, bend notes and the blank's overall size. Weld beads come in with their weld symbols; a weldment gets its cut list table. Then every view moves with its annotations until nothing reaches off the frame, onto the title block or into another view; when they cannot fit, the iso view is left out, then the next larger sheet is tried, up to max_sheet (None: `sheet` only). Returns `sheet`, `fit` ({fits, tried}) and `problems` (check_drawing). keep_open=True keeps it as the current drawing to refine with the other drawing tools. Save the part first (save_document): the drawing refers to its file.

輸入參數path必填scalesheetkeep_openmax_sheet

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": "front", "ref": "edge:-x", "to": "hole:H1"}, {"view": "front", "chain": ["edge:-x", "hole:H1", "hole:H2"]}], "callouts": [{"view": "front", "hole": "H1"}], "symbols": [{"type": "datum", "view": "top", "ref": "edge:-z", "label": "A"}, {"type": "gtol", "view": "top", "ref": "edge:+z", "symbol": "parallelism", "tolerance": "0.05", "datums": ["A"]}, {"type": "surface_finish", ...}], "notes": ["..."], "tables": [[["a", "b"], ...]], "gear_table": {"kind": "spur", "teeth": 20, "module": 2}, "props": {"material": "from part"}, "layout": "auto", "max_sheet": "A1", "fit": true}. Last, every view moves with its annotations, and the notes and tables, until nothing reaches off the frame, onto the title block or into another view; when they cannot fit, it is built again on the next larger sheet, up to max_sheet ("fit": false leaves everything where the spec put it). Saved to path when given. Returns what was made, `sheet`, `fit` ({fits, tried}) and the problems check_drawing finds.

輸入參數pathspec必填

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.

輸入參數partpathsheetaction必填

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.

輸入參數properties必填

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.5x the parent's). - 'flat_pattern': a sheet metal part unfolded, with bend lines, bend notes and its overall size dimensioned; at=[x, y], or beside='<view>' on side. Placed with room for dimensions, past views in the way (gap_mm to fix the gap). scale '1:2'. A section or detail view keeps its label's name; `name` becomes an alias for it.

輸入參數atflipkindnamepartsidelabelscalebesidecentergap_mmnormal另有 4 個

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.

輸入參數atname必填sidealignscalebesidedeletegap_mmdisplaynew_nametangent_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.

輸入參數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).

輸入參數viewkinds

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 ...). Returns ids, values, boxes, and warnings on overlaps.

輸入參數toref必填sideview必填styledirectionoffset_mm

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, symmetry, runout or total_runout; tolerance '0.05'; datums ['A', 'B']; diameter=True for a round zone; material_condition 'MMC' / 'LMC'; - 'weld': ISO 2553, weld={'weld': 'fillet' (square, v, bevel, v_root, bevel_root, u, j, backing, plug, spot, seam), 'size': 'a4', 'length': '100' or '3x50 (100)', 'side': 'arrow' / 'other' / 'both', 'contour': 'flat' / 'convex' / 'concave', 'all_around': true, 'field': true}. ref as in add_dimension. at=[x, y] places it (sheet mm), by default off the view, clear of text.

輸入參數atref必填type必填view必填weldcountlabeldatumssymbolprocessdiameterroughness另有 2 個

add_note

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

輸入參數attext必填height_mm

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, description, length, angles) and total weld length. at=[x, y] its top-left corner, by default free room.

輸入參數atgearrowstitlecut_listtext_height_mmcolumn_widths_mm

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

輸入參數atfittextdeleteprefixsuffixdiametricprecisiontoleranceannotation_id必填

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.

輸入參數mainscalearrange_dimensions

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.

輸入參數path必填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 has no unsaved changes.

輸入參數savetitle

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

輸入參數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; the result gives the component count. Drawings: drawing_file(action='open').

輸入參數kindpath必填

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 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; brief=True gives only name, path, fixed.

輸入參數namebriefmates

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, 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 "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. Several at once: mates=[{"comp_a": "Bolt-1", "face_a": "#3", "comp_b": "Plate-1", "face_b": "#12", "mate_type": "concentric"}, ...], each with the arguments above. stop_on_error=True stops at the first that fails; the mates before it stay. Returns a result per mate (its name and dimension, or the error), how many were added, failed and not tried, and the mate count.

輸入參數flipmatescomp_acomp_bface_aface_bangle_degmate_typedistance_mmstop_on_error

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

版本歷史

2
  1. v0.2.0最新Oct 30, 2026
  2. v0.1.0Oct 29, 2026

評分

已滿足適用檢查項的 90%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分
  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具必需15 分
  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分