dsh-cad-studio 0.9.0 → 0.9.1
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.
- package/index.js +14 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1347,6 +1347,20 @@ def _prim(op, _cur=None):
|
|
|
1347
1347
|
raise RuntimeError("extrude 需要 h 或 dir(当前的挤出向量长度为 0)")
|
|
1348
1348
|
return Part.Face(Part.makePolygon(ps + [ps[0]])).extrude(vec)
|
|
1349
1349
|
if k == "revolve":
|
|
1350
|
+
if op.get("sketch"):
|
|
1351
|
+
face = Part.Face(_sketch(str(op["sketch"])))
|
|
1352
|
+
rev = face.revolve(_v3(op.get("origin")), _dir(op.get("axis"), (0.0, 0.0, 1.0)), float(op.get("angle", 360.0)))
|
|
1353
|
+
# A revolve of a face yields a shell; a full turn closes it, but only
|
|
1354
|
+
# becomes a solid after we say so. Volume 0 means "still a shell".
|
|
1355
|
+
if abs(rev.Volume) < 1e-9 and rev.Shells:
|
|
1356
|
+
try:
|
|
1357
|
+
rev = Part.makeSolid(rev.Shells[0])
|
|
1358
|
+
except Exception:
|
|
1359
|
+
pass
|
|
1360
|
+
if abs(rev.Volume) < 1e-9:
|
|
1361
|
+
# Do not hand a zero-volume shell downstream: say it out loud.
|
|
1362
|
+
raise RuntimeError("草图旋转得到的是壳体、没有闭合(需要 sewShape 缝合);先用挤出,或把草图轮廓贴住旋转轴")
|
|
1363
|
+
return rev
|
|
1350
1364
|
ps = [Vector(float(p[0]), 0.0, float(p[1])) for p in op["points"]]
|
|
1351
1365
|
ang = float(op.get("angle", 360.0))
|
|
1352
1366
|
return Part.Face(Part.makePolygon(ps + [ps[0]])).revolve(Vector(0.0, 0.0, 0.0), Vector(0.0, 0.0, 1.0), ang)
|