feat: establish reproducible FreeCAD web compatibility baseline

This commit is contained in:
2026-08-10 16:11:38 -04:00
parent e5a5d74dbc
commit b962a5c3b5
733 changed files with 349081 additions and 647 deletions

View File

@@ -5,6 +5,18 @@ import FreeCAD as App
import Part
def make_feature_shape(type_id, properties):
document = App.newDocument("GoldenPrimitive")
try:
feature = document.addObject(type_id, "Primitive")
for name, value in properties.items():
setattr(feature, name, value)
document.recompute()
return feature.Shape.copy()
finally:
App.closeDocument(document.Name)
def make_shape(operation):
kind = operation["type"]
if kind == "box":
@@ -15,6 +27,32 @@ def make_shape(operation):
shape = Part.makeSphere(operation["radius"])
elif kind == "cone":
shape = Part.makeCone(operation["radius1"], operation["radius2"], operation["height"], App.Vector(0, 0, 0), App.Vector(0, 0, 1), operation["angle"])
elif kind == "ellipsoid":
shape = make_feature_shape("Part::Ellipsoid", {
"Radius1": operation["radius1"], "Radius2": operation["radius2"], "Radius3": operation["radius3"],
"Angle1": operation["angle1"], "Angle2": operation["angle2"], "Angle3": operation["angle3"],
})
elif kind == "torus":
shape = make_feature_shape("Part::Torus", {
"Radius1": operation["radius1"], "Radius2": operation["radius2"],
"Angle1": operation["angle1"], "Angle2": operation["angle2"], "Angle3": operation["angle3"],
})
elif kind == "prism":
shape = make_feature_shape("Part::Prism", {
"Polygon": operation["polygon"], "Circumradius": operation["circumradius"], "Height": operation["height"],
"FirstAngle": operation["firstAngle"], "SecondAngle": operation["secondAngle"],
})
elif kind == "wedge":
shape = make_feature_shape("Part::Wedge", {
"Xmin": operation["xmin"], "Ymin": operation["ymin"], "Zmin": operation["zmin"],
"Z2min": operation["z2min"], "X2min": operation["x2min"], "Xmax": operation["xmax"],
"Ymax": operation["ymax"], "Zmax": operation["zmax"], "Z2max": operation["z2max"], "X2max": operation["x2max"],
})
elif kind == "helix":
shape = make_feature_shape("Part::Helix", {
"Pitch": operation["pitch"], "Height": operation["height"], "Radius": operation["radius"],
"Angle": operation["angle"], "SegmentLength": operation["segmentLength"],
})
elif kind in ("cut", "fuse", "common"):
base = make_shape(operation["base"])
tool = make_shape(operation["tool"])