dsh-sw-3d-preview: View STEP/STL Files in the DSH Preview Panel and Return Annotations

Introduction

The DSH plugin platform puts the “everything is a plugin” philosophy into practice, allowing developers to extend functionality on demand. In the workflow where an agent drives SOLIDWORKS modeling, the output after a model is built is text-only—no one can see whether the shape is correct, and the model itself can’t see either. The dsh-sw-3d-preview plugin fills this gap: it parses the STEP/STL/OBJ files delivered by the agent into a mesh and renders it in the file preview panel, so you can visually inspect and confirm, then turn “this face is wrong” into a set of face IDs + coordinates to send back to the agent for correction.

Plugin package: dsh-sw-3d-preview, version 0.2.2, maintained by monta-6969, MIT licensed. It does not build models, modify models, or launch SOLIDWORKS—modeling is sw-mcp’s job. This plugin is solely responsible for “seeing” and “articulating what’s wrong.”

Core Features

Parse and Render 3D Files

The plugin supports previewing files in STEP, STL, and OBJ formats, as well as the native SLDPRT format (with a four-level fallback strategy).

  • .step / .stp: Triangulated via cadquery-ocp; faces, edges, vertices, and cross-sections are all available
  • .stl / .obj: Built-in parser; triangles only, merged by normal; edge wireframe is empty
  • .sldprt / .sldasm: Native format is not parsed; handled via the four-level fallback

Interactive Operations

In the file preview panel, you can perform the following operations via the toolbar and right-click context menu:

  • Section: Select an axis and drag to inspect internal structure; “Cap” computes a true cross-section geometrically (not a fake plane)
  • Precision: High/Medium/Low three levels, default is Medium. A warning is shown if the triangle count is too high
  • Picking: Hover to highlight, click to select; the info card shows face ID (area + normal), edge ID (length + endpoints), or vertex coordinates
  • Three-point sampling: Press Alt and click 3 times on the same face to record 3 points in the model coordinate system, which can be used to reposition that face in SOLIDWORKS
  • Marker: Double-click a face/edge/vertex (sketch polylines and endpoints also work) to place a marker
  • Sketch overlay: Toggle the “Sketch” switch in the toolbar to superimpose the sketch outline from sw-mcp
  • Multi-select sketches: Ctrl/Cmd + left-click to toggle selection; the info bar shows total length; right-click for “Select All in This Sketch” and “Fill Selected into Dialog”
  • Hand off to agent: “Save Annotation” writes to disk → “Generate Handoff” produces a Markdown file; feed the path to the agent

Right-click menu items like “Add Sketch / Fillet / Set Datum Point” only generate natural-language instructions filled into the input box. The agent decides whether to actually execute them in SOLIDWORKS. The plugin itself never modifies the model.

Installation & Activation

Environment Requirements

  • Node.js ≥ 22
  • Python with cadquery-ocp installed (STEP triangulation depends on it entirely)

Install the Python dependency:

py -3 -m pip install cadquery-ocp

The plugin locates Python in this order: SW_3D_PREVIEW_PYTHON environment variable → %LOCALAPPDATA%\sw-mcp\.venv → the sw-mcp repo path in the profile → sw-mcp\.venv adjacent to the plugin → py -3 / python / python3. To specify a path, set the environment variable and restart DSH:

[Environment]::SetEnvironmentVariable('SW_3D_PREVIEW_PYTHON','C:\Python312\python.exe','User')

Install into a Profile

Choose either of the following two approaches:

Option A: For development — directory junction

Add the dependency and bundle to the profile’s package.json, then create a junction:

New-Item -ItemType Junction `
  -Path   "$env:USERPROFILE\.dsh\profiles\desktop\node_modules\dsh-sw-3d-preview" `
  -Target "D:\tools\dsh-sw-3d-preview"

Option B: For distribution — install the packaged tgz

npm run package
npm install --prefix "$env:USERPROFILE\.dsh\profiles\desktop" "<plugin-dir>\dist\dsh-sw-3d-preview-0.2.2.tgz"

Both approaches require adding dsh-sw-3d-preview to dsh.profile.bundles in the profile’s package.json.

Verify Installation

Confirm it’s installed: without authentication, all 8 /sw3d/* routes should return 401 (routes exist, auth gate is active); any 404 means the plugin is not mounted. Use your current DSH port:

$base = "http://127.0.0.1:61489"
foreach ($p in "/sw3d/ping","/sw3d/resolve","/sw3d/mesh","/sw3d/three.js","/sw3d/annotation","/sw3d/handoff","/sw3d/snapshot","/sw3d/sketches") {
  try { $null = Invoke-WebRequest "$base$p" -UseBasicParsing -ErrorAction Stop; "$p -> 200" }
  catch { "$p -> $([int]$_.Exception.Response.StatusCode)" }
}
npm run verify:python   # "ok": true and "ocp": true in the output means STEP is available

Typical Usage

View and Confirm Model Shape

Open any model file and the preview panel will render it. Use the “Section” tool in the toolbar to select an axis and drag to inspect internal structure; “Cap” computes a true cross-section geometrically.

Pick Faces/Edges/Vertices and Mark

After selecting a face/edge/vertex, the info card displays face ID (area + normal), edge ID (length + endpoints), or vertex coordinates. Double-click to place a marker. Press Alt and click 3 times on the same face for three-point sampling, recording 3 points in the model coordinate system.

Overlay Sketch

Toggle the “Sketch” switch in the toolbar to superimpose the sketch outline from sw-mcp for side-by-side comparison. Ctrl/Cmd + left-click to toggle selection; the info bar shows total length; right-click for “Select All in This Sketch” and “Fill Selected into Dialog.”

Hand Off to Agent

“Save Annotation” writes to disk → “Generate Handoff” produces a Markdown file; feed the path to the agent. The agent can then modify the model based on the annotations.

Use Cases & Caveats

Use Cases

  • Driving SOLIDWORKS modeling via an agent, with the need to visually inspect the model and provide feedback
  • Previewing and annotating STEP/STL files
  • Sending annotation data (face IDs + coordinates) back to the agent

Caveats

  1. SLDPRT native parts: The plugin does not parse the native format. You must place a same-name STEP file alongside it, or ask the agent to first deliver kind="step" to export one.
  2. Markers are in-memory only: Refreshing the page loses them. To persist, you must click “Save Annotation.” Double-clicking the same location stacks multiple markers (no deduplication).
  3. Readings have deviation: Sketch arcs are approximated by polylines; the “Total X.X mm” in the info bar is the sum of chord lengths, always less than the true arc length.
  4. No undo: Clicking on empty space or pressing Esc immediately clears the selection. There is no undo stack.
  5. Visual output unverified on real hardware: All automated tests run against a fake WebGL renderer, verifying only code paths and data—never producing a single pixel. The first thing to do after installing on a real machine is to load a real STEP file and check each feature.
  6. Units are treated as mm.

Risk Notice

The plugin runs with the current DSH process’s privileges. Review the source code and license before installing.

Summary

dsh-sw-3d-preview views STEP/STL/OBJ models in the DSH file preview panel, supporting sectioning, rotation, edge/face/vertex picking, and annotation feedback. It “renders” the model built by the agent and “articulates what’s wrong,” serving as the “eyes” in the SOLIDWORKS modeling automation pipeline.

  • Plugin directory: https://www.skillhub.cn/plugins/monta-6969/dsh-sw-3d-preview
  • GitHub: https://github.com/monta-6969/dsh-sw-3d-preview
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye