[OpenSCAD] Fix bug in resize code

The resize code must recompute some kinds of objects prior to requesting
their bounding box, or the bounding box can be invalid.
This commit is contained in:
Chris Hennes
2021-03-25 13:48:28 -05:00
committed by wwmayer
parent 241be51afa
commit a0464d1b00
2 changed files with 13 additions and 0 deletions

View File

@@ -312,6 +312,18 @@ polyhedron(
self.assertAlmostEqual (object.Shape.Volume, 8.000000, 6)
FreeCAD.closeDocument(doc.Name)
# Make sure to test something that isn't just a box (where the bounding box is trivial)
doc = self.utility_create_scad("""
resize(newsize = [0,0,10], auto = [0,0,0]) {
sphere($fn = 96, $fa = 12, $fs = 2, r = 8.5);
}""", "resize_non_uniform_sphere")
object = doc.ActiveObject
self.assertTrue (object is not None)
self.assertAlmostEqual (object.Shape.BoundBox.XLength, 2*8.5, 1)
self.assertAlmostEqual (object.Shape.BoundBox.YLength, 2*8.5, 1)
self.assertAlmostEqual (object.Shape.BoundBox.ZLength, 10.0, 1)
FreeCAD.closeDocument(doc.Name)
def test_import_surface(self):
# Workaround for absolute vs. relative path issue
# Inside the OpenSCAD file an absolute path name to Surface.dat is used

View File

@@ -469,6 +469,7 @@ def p_resize_action(p):
auto = p[3]['auto']
print(new_size)
print(auto)
p[6][0].recompute()
old_bbox = p[6][0].Shape.BoundBox
print ("Old bounding box: " + str(old_bbox))
old_size = [old_bbox.XLength, old_bbox.YLength, old_bbox.ZLength]