OpenSCAD: Ensure complex fuse has no extra placement

This commit is contained in:
Chris Hennes
2022-11-30 18:30:06 -06:00
parent 7310ff4bb8
commit 3f118b52bc
2 changed files with 34 additions and 0 deletions

View File

@@ -502,3 +502,36 @@ resize(newsize = [0,0,10], auto = [0,0,0]) {
doc = self.utility_create_scad(content, "empty_union")
self.assertEqual (len(doc.RootObjects), 1)
FreeCAD.closeDocument(doc.Name)
def test_complex_fuse_no_placement(self):
# Issue #7878 - https://github.com/FreeCAD/FreeCAD/issues/7878
csg_data = """
group() {
multmatrix([[1, 0, 0, 0], [0, 1, 0, -127], [0, 0, 1, -6], [0, 0, 0, 1]]) {
union() {
group() {
difference() {
cube(size = [4, 106.538, 12], center = false);
group() {
polyhedron(points = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, 1], [0, 1, 1]], faces = [[0, 1, 2], [5, 4, 3], [3, 1, 0], [1, 3, 4], [0, 2, 3], [5, 3, 2], [4, 2, 1], [2, 4, 5]], convexity = 1);
}
}
}
polyhedron(points = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, 1], [0, 1, 1]], faces = [[0, 1, 2], [5, 4, 3], [3, 1, 0], [1, 3, 4], [0, 2, 3], [5, 3, 2], [4, 2, 1], [2, 4, 5]], convexity = 1);
polyhedron(points = [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, 1], [0, 1, 1]], faces = [[0, 1, 2], [5, 4, 3], [3, 1, 0], [1, 3, 4], [0, 2, 3], [5, 3, 2], [4, 2, 1], [2, 4, 5]], convexity = 1);
}
}
multmatrix([[1, 0, 0, 6.4], [0, 1, 0, -125], [0, 0, 1, -40], [0, 0, 0, 1]]) {
difference() {
cylinder($fn = 0, $fa = 12, $fs = 2, h = 80, r1 = 8, r2 = 8, center = false);
multmatrix([[1, 0, 0, -14.4], [0, 1, 0, -8], [0, 0, 1, -5], [0, 0, 0, 1]]) {
cube(size = [8, 16, 90], center = false);
}
}
}
}
"""
doc = self.utility_create_scad(csg_data, "complex-fuse")
self.assertEqual (doc.RootObjects[0].Placement, FreeCAD.Placement())
FreeCAD.closeDocument(doc.Name)

View File

@@ -634,6 +634,7 @@ def fuse(lst,name):
if gui:
myfuse.Base.ViewObject.hide()
myfuse.Tool.ViewObject.hide()
myfuse.Placement = FreeCAD.Placement()
return(myfuse)
def p_empty_union_action(p):