dsh-cad-studio 0.25.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -0
  2. package/index.js +26 -2
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -24,6 +24,7 @@ DeepSeek Harness 的 CAD 插件:**把 FreeCAD 桥接成给 AI 用的工具**
24
24
  | 模型清单 | `cad_studio_scene`(`action: list / delete / rename`)——面板里那条列表就是它;探查脚本留下的卡片可以直接删 |
25
25
  | 模型改名 / 复制 | `cad_studio_doc {action:"rename", name, to}` 与 `{action:"duplicate", name, to}`:改名会同步列表里的标题与 `docKey`,复制会得到一条独立的新场景(副本不继承运行历史与撤销栈);两者都可 `cad_studio_undo` 回退 |
26
26
  | 几何自检 | `cad_studio_check {source}` 在导出/打印前问一次:是否有效实体、外壳是否闭合、每个实体体积多少,返回中文问题清单(零体积 / 外壳未闭合 / 几何无效 / 没有实体) |
27
+ | 拔模挤出 | `{kind:"extrude", sketch:"S1", h:20, draft:3}` 按 3° 拔模:截面按 `h*tan(3°)` 偏移后 loft 成体,正角度内收、负角度外放 |
27
28
  | 展开图 | `cad_studio_unfold {source, target:"…/net.dxf"}` 把板类零件按共享边摊平成下料图(面片等距铺开,面积与模型一致;孔各自成环;圆柱/圆角等曲面报 `curvedSkipped` 而不是瞎编),可写 DXF 或 SVG |
28
29
  | 打印网格 | `cad_studio_mesh {source, target:"…/x.stl"}` 三角化 + 去重合并点/面、修形变、统一法向,可选 `fillHoles`、`targetSize`(减面);回报修复前后的 facets/points,避免「导出成功但网格是碎的」 |
29
30
  | 旋转体与凹槽 | `revolve` 的 `axis` 取草图平面内的轴(`"Y"` 或 `[0,1,0]`)才是实体;垂直轴(XY 草图的 Z)只会扫出零厚度圆环,插件会直接报错。凹槽=`{kind:"cut", with:{kind:"revolve", …}}`,不需要单独 op |
package/index.js CHANGED
@@ -1722,8 +1722,32 @@ def _prim(op, _cur=None):
1722
1722
  return Part.makeTorus(float(op["r1"]), float(op["r2"]), at, _dir(op.get("axis")))
1723
1723
  if k == "extrude":
1724
1724
  if op.get("sketch"):
1725
- face = Part.Face(_sketch(str(op["sketch"])))
1726
- return face.extrude(_dir(op.get("dir"), (0.0, 0.0, float(op.get("h") or 10.0))))
1725
+ wire = _sketch(str(op["sketch"]))
1726
+ vec = _dir(op.get("dir"), (0.0, 0.0, float(op.get("h") or 10.0)))
1727
+ draft = float(op.get("draft", 0.0) or 0.0)
1728
+ if abs(draft) < 1e-9:
1729
+ return Part.Face(wire).extrude(vec)
1730
+ # Draft: the section shrinks toward the far end, so the wall leans by
1731
+ # the requested angle instead of going straight up. Offsetting the
1732
+ # section in its own plane and lofting keeps the sides planar; a
1733
+ # plain extrude plus a taper would need a real BRepOffsetAPI call
1734
+ # that FreeCAD 0.20 does not expose to Python.
1735
+ if abs(draft) >= 89.0:
1736
+ raise RuntimeError("draft 需要 -89 到 89 度之间的角度")
1737
+ drop = abs(vec.Length) * math.tan(math.radians(abs(draft)))
1738
+ sign = -1.0 if draft > 0 else 1.0
1739
+ try:
1740
+ ring = wire.makeOffset2D(sign * drop, 0, False, False)
1741
+ except Exception:
1742
+ raise RuntimeError("draft 无法偏移这个截面:向内缩 %.3f mm 后没有面积了(减小角度或加大截面)" % drop)
1743
+ if ring.ShapeType != "Wire":
1744
+ raise RuntimeError("draft 无法偏移这个截面(可能是自交或太窄:需要向内缩 %.3f mm)" % drop)
1745
+ ring = ring.copy()
1746
+ ring.translate(vec)
1747
+ solid = Part.makeLoft([wire, ring], True)
1748
+ if abs(solid.Volume) < 1e-9:
1749
+ raise RuntimeError("draft 得到零体积:截面缩 %.3f mm 后已经没有面积了,减小角度" % drop)
1750
+ return solid
1727
1751
  base = float(op.get("base", 0.0))
1728
1752
  h = float(op.get("h", 0.0))
1729
1753
  # Points may be 2D (z = base) or 3D; dir replaces the +Z extrusion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cad-studio",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "type": "module",
5
5
  "description": "CAD Studio — FreeCAD 桥(给 AI 的 14 个工具)+ Web 右栏 3D 面板:建模/装配/关节运动/出图/多页签查看",
6
6
  "exports": {