dsh-cad-studio 0.12.0 → 0.13.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 (2) hide show
  1. package/index.js +8 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -2406,6 +2406,7 @@ if not _shapes:
2406
2406
  __out = {"ok": False, "error": "nothing to section"}
2407
2407
  else:
2408
2408
  _loops = []
2409
+ _wl = []
2409
2410
  _area = 0.0
2410
2411
  _per = 0.0
2411
2412
  for _s in _shapes:
@@ -2414,6 +2415,7 @@ else:
2414
2415
  except Exception as _e:
2415
2416
  _ws = []
2416
2417
  for _w in _ws:
2418
+ _wl.append(_w)
2417
2419
  _pts = _w.discretize(Deflection=0.15)
2418
2420
  if len(_pts) < 3:
2419
2421
  continue
@@ -2428,7 +2430,8 @@ else:
2428
2430
  pass
2429
2431
  __out = {"ok": True, "axis": _AX, "at": _AT, "loops": len(_loops),
2430
2432
  "area": round(_area, 3), "perimeter": round(_per, 3)}
2431
- _svg = ${target ? JSON.stringify(String(target)) : 'None'}
2433
+ _svg = ${target && !/\.dxf$/i.test(String(target)) ? JSON.stringify(String(target)) : 'None'}
2434
+ _dxf = ${target && /\.dxf$/i.test(String(target)) ? JSON.stringify(String(target)) : 'None'}
2432
2435
  if _svg and _loops:
2433
2436
  # Project the 3D loop points to the plane's 2D coordinates.
2434
2437
  def _uv(_p, _ax):
@@ -2457,6 +2460,10 @@ else:
2457
2460
  _f.write("\\n".join(_parts))
2458
2461
  __out["svg"] = _svg
2459
2462
  __out["svg_size"] = [round(_w, 2), round(_h, 2)]
2463
+ if _wl and _svg is None and _dxf:
2464
+ import importDXF
2465
+ importDXF.export([Part.makeCompound(_wl)], _dxf)
2466
+ __out["dxf"] = _dxf
2460
2467
  `
2461
2468
  return bridge.run(py, { title: 'section', publishHint: false })
2462
2469
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-cad-studio",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "type": "module",
5
5
  "description": "CAD Studio — FreeCAD 桥(给 AI 的 14 个工具)+ Web 右栏 3D 面板:建模/装配/关节运动/出图/多页签查看",
6
6
  "exports": {