前言¶
在用 DeepSeek Harness(DSH)開發涉及 CAD 建模的任務時,常見情況是需要在 dsh 代理進程裏調用 Rhino 8 的建模 API。傳統做法要麼在 dsh 裏通過 HTTP 調用遠程 Rhino,要麼在本地手動啓動 Rhino 並用腳本橋接。前者增加網絡跳數和延遲,後者需要額外的腳本編寫和端口管理。
dsh-rhino 插件提供了一種更直接的方式:在 dsh 進程裏直接控制一個本地 Rhino 8 會話,在 Rhino 的 UI 線程上運行 IronPython 代碼,並從 dsh 拿到建模結果和視口截圖。
這是什麼¶
dsh-rhino 是一個 DeepSeek Harness 插件,由維護者 1gokd 開發。它通過一個橋接腳本將 Rhino 8 的 IronPython 引擎暴露給 dsh,使代理可以在本地驅動 Rhino 的建模流程、讀取文檔對象和捕獲視口。
核心功能¶
| 工具 | 功能 |
|---|---|
rhino_start |
啓動 Rhino 8 並掛載橋接(或提示手動掛載已運行的會話) |
rhino_status |
檢查橋接是否可達,讀取當前活動文檔信息 |
rhino_run |
在 Rhino 的 UI 線程上執行 IronPython 2.7 代碼,返回可 JSON 序列化的結果 |
rhino_objects |
列出文檔中的對象,包含 id、幾何類型、圖層和名稱 |
rhino_capture |
執行 Zoom-to-Extents 並將活動視口捕獲爲 PNG |
安裝與啓用¶
安裝插件:
# 從本地檢出目錄安裝
dsh plugin install ./dsh-rhino
# 或從 git 安裝
dsh plugin install https://github.com/1gokd/dsh-rhino
安裝後,在配置文件中啓用該 bundle:
dsh plugin list
dsh plugin enable dsh-rhino
典型用法¶
在 dsh agent 中調用 rhino_start,等待橋接端口就緒後,執行建模代碼:
> open rhino and draw a 100mm cube
代理調用 rhino_start,等待橋接端口,然後運行:
import Rhino.Geometry as rg
b = rg.Brep.CreateFromBox(rg.BoundingBox(rg.Point3d(0,0,0), rg.Point3d(100,100,100)))
sc.doc.Objects.AddBrep(b)
sc.doc.Views.Redraw()
RESULT = {"ok": True}
手動掛載橋接¶
如果 Rhino 已經運行,可在 Rhino 命令行中手動加載橋接腳本:
_-RunPythonScript ("C:\Users\<you>\.dsh\rhino\rhino_bridge.py")
適用場景與注意¶
- 適合需要在 dsh 裏進行本地 CAD 建模、文檔檢查和視口截圖的場景。
- 插件以當前 dsh 進程的權限運行,安裝前建議檢查源碼與許可證(MIT)。
小結¶
dsh-rhino 讓 DeepSeek Harness 能夠直接驅動 Rhino 8 會話,在 UI 線程上執行 IronPython 建模代碼,並從 dsh 獲取建模結果與視口截圖。安裝後啓用 bundle,即可在 agent 中調用相關工具。