run_script
Execute Python in live SolidWorks to create or edit parts and assemblies and receive geometry, mass, clash, sketch, and image verification in one report.
Instructions
Run Python against the live SolidWorks: a whole part in one call, or what no tool covers; only when the server runs with --allow-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).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | No | ||
| path | No | ||
| image | No |