Introduction¶
DSH has many plugins related to code and documentation, but when you actually get a mechanical part PRT file, the common approach is to switch to NX to take a screenshot, then paste it back into the chat window. Screenshots only show shape; information like faces, edges, and the feature tree cannot be passed in at all, and if the model changes, you have to screenshot again.
qiko0721/dsh-ug-viewer takes a different route: rendering UG/NX models directly in the DSH Web GUI. Clicking geometry with the mouse automatically compiles the selection into the context sent to the AI. Below introduces this plugin’s features, installation, and actual usage flow.
What is this¶
The plugin name is dsh-ug-viewer, maintained by QIKO0721, and is categorized as a client-side plugin. It solves the problem: turning model review in DSH from “looking at screenshots” to “movable, selectable, and queryable”.
Its positioning is clear—not pasting images in, but moving the WebGL viewport, geometry selection, and feature tree into the sidebar. STL/OBJ can be dragged in to rotate directly; PRT is handled by the local NX.
Core Features¶
Model Preview¶
- STL/OBJ: Drag into the viewport for direct rendering, Middle-click to rotate, Scroll to zoom, Left-click to pan.
- Direct PRT Preview: No STL preprocessing needed; the background NX calls NX Open to triangulate the solid by faces and renders it.
- PRTs with only sketches: Rendered as wireframes, arcs discretized into polylines.
Geometry Selection¶
Supported selection targets and feedback methods are as follows:
| What can be selected | How to select | Feedback |
|---|---|---|
| Faces | Click the middle of the face | The whole face turns blue |
| Edges | Click within 6px of the face boundary | The whole edge turns red |
| Features | Click a row in the left column feature tree | The body associated with that feature turns blue |
| Sketch curves | Click a line in wireframe mode | The whole curve turns red |
| Sketch points | Click the small cross | Overlay displays “Point #N” |
| Curve intersections | Click the intersection point | Overlay displays “Intersection #N” |
| Sketch constraints | Expand the sketch in the feature tree | Overlay displays constraint type |
Full multi-select support: Click to add, click again to cancel, click blank space to clear.
Feature Analysis¶
The left-side persistent feature tree (collapsible), loads automatically when opening a PRT, showing feature type, parameter expressions, and parent-child dependencies. Sketches can be expanded to view constraints (README mentions 22-44 constraints), covering types like coincident, tangent, radius, angle, etc.
In-place Q&A¶
There is a chat bar below the viewport, directly calling the Host’s llm service. After selecting geometry and typing a question, pressing Enter, the plugin automatically compiles the selected faces, edges, features, constraints, curves, points, and intersections into the context along with the question, returning it streamingly without needing to switch pages.
Interface¶
Three-column layout: Directory | Feature Tree | Viewport. Both Directory and Feature Tree are collapsible, controlled by the ☰ and ▤ icons on the toolbar left. Also includes view presets (Isometric/Front/Top/Right), wireframe, auto-rotate, screenshot, and reset.
Installation and Enablement¶
Prerequisites are DSH (Web GUI); NX 12+ is only needed for PRT preview and feature analysis; for viewing STL/OBJ only, it is not needed. The README mentions NX 12 has embedded Python 3.6, and the plugin calls NX Open via run_journal.exe.
# 1. Clone to any directory
git clone https://github.com/QIKO0721/dsh-ug-viewer.git
cd dsh-ug-viewer
# 2. Install into DSH (choose one)
dsh plugin --profile web add link:$(pwd)
# or
plugin_manager { action: install_bundle, target: "<absolute path>" }
After installation, refresh the page, and the “UG Model Preview” will appear in the sidebar.
Configuration¶
Edit cordis.patch.yml and replace the paths with your own:
config:
roots:
- 'D:\models' # Model directory (can write multiple)
maxFileBytes: 100663296 # Single file limit (96 MB)
maxDepth: 3 # Recursion depth
maxModels: 400 # List limit
runJournalExe: 'D:\UG\NXBIN\run_journal.exe' # NX journal runner
analyzeTimeoutMs: 180000 # Analysis timeout
You can also choose not to modify the config file and use the “Select Directory” button in the panel to switch at runtime; the selection is saved to ~/.dsh/dsh-ug-viewer.json.
Typical Usage¶
A reproducible workflow is: configure the model directory into roots, open the plugin sidebar; select a PRT in the directory, the viewport loads the model, and the feature tree appears automatically; click a face with the mouse, that face highlights; type “Why is this face this shape” in the chat bar below the viewport, press Enter, and the selected geometry information is sent to the Host’s llm along with the question, with the answer displayed directly in the bar.
If you want to verify if the geometry export chain is working, the plugin comes with two test scripts:
cd dsh-ug-viewer
node test/geometry-once.mjs # Test PRT geometry export
node test/chat-once.mjs # Test panel chat interface
These scripts require DSH to be running and the plugin to be installed.
Applicable Scenarios and Notes¶
Suitable for people who frequently review UG/NX parts in DSH and want to query AI immediately after selecting geometry. PRT-related capabilities rely on having NX 12+ installed locally and runJournalExe configured correctly; scenarios using only STL/OBJ do not touch NX.
A few limitations worth knowing:
- Features cannot be precisely highlighted to specific faces. The NX external API does not expose the mapping from feature to face,
GetEntities()only returns curves and datums, so when a feature is selected, only the associated body is highlighted. - A body may be generated by multiple features, so feature highlighting can be “excessive”.
- Non-solid parts cannot select faces; there are only curves without B-rep faces.
- Panel chat does not go into session logs; refresh and it forgets.
- This NX 12 environment does not have the
NXOpen.UFmodule, so the plugin can only use the NXOpen interface.
The plugin runs with the permissions of the current DSH process. The README installation uses the local link method, meaning after cloning the source code locally, it references the directory, allowing code to be read directly before installation. It is recommended to read the source code once before installing to confirm that configuration items and journal calls match your environment, then decide whether to enable it. The license is MIT.
Summary¶
The value of dsh-ug-viewer lies in combining the three model review actions into one sidebar: rotating the model, clicking geometry, and asking AI, with the selection serving as context directly in the conversation. The shortcomings are also clearly stated, mainly the lack of a mapping relationship between features and faces exposed by the NX API itself, so don’t expect it to achieve precise feature positioning in CAD.
Plugin page in the community directory: https://www.skillhub.cn/plugins/QIKO0721/dsh-ug-viewer
Source code: https://github.com/QIKO0721/dsh-ug-viewer