From 46b0043b490ec99ac57b51440b50c228a5951a01 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 29 Mar 2021 13:58:52 -0500 Subject: [PATCH 1/2] [OpenSCAD] Add additional recompute() logic --- src/Mod/OpenSCAD/importCSG.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mod/OpenSCAD/importCSG.py b/src/Mod/OpenSCAD/importCSG.py index 1cc8ad4845..315eb94d44 100644 --- a/src/Mod/OpenSCAD/importCSG.py +++ b/src/Mod/OpenSCAD/importCSG.py @@ -463,13 +463,14 @@ def p_minkowski_action(p): def p_resize_action(p): ''' resize_action : resize LPAREN keywordargument_list RPAREN OBRACE block_list EBRACE ''' - import Draft print(p[3]) new_size = p[3]['newsize'] auto = p[3]['auto'] print(new_size) print(auto) p[6][0].recompute() + if p[6][0].Shape.isNull(): + doc.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] @@ -482,7 +483,6 @@ def p_resize_action(p): # Calculate a transform matrix from the current bounding box to the new one: transform_matrix = FreeCAD.Matrix() - #new_part.Shape = part.Shape.transformGeometry(transform_matrix) scale = FreeCAD.Vector(float(new_size[0])/old_size[0], float(new_size[1])/old_size[1], @@ -978,10 +978,10 @@ def p_multmatrix_action(p): part.ViewObject.hide() else : if printverbose: print("Transform Geometry") -# Need to recompute to stop transformGeometry causing a crash - doc.recompute() + part.recompute() + if part.Shape.isNull(): + doc.recompute() new_part = doc.addObject("Part::Feature","Matrix Deformation") - # new_part.Shape = part.Base.Shape.transformGeometry(transform_matrix) new_part.Shape = part.Shape.transformGeometry(transform_matrix) if gui: part.ViewObject.hide() From 9540cf0bbdc3ef4af8d2b382f0600da069864c6d Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 29 Mar 2021 13:59:03 -0500 Subject: [PATCH 2/2] [OpenSCAD] Add piecewise helix for OCCT < 7.5 Address a hang when using older versions of OCC to create a rotated extrusion. This approximates the auxilliary spine as set of line segments formed from the helix, rather than using the helix directly. --- src/Mod/OpenSCAD/OpenSCADFeatures.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Mod/OpenSCAD/OpenSCADFeatures.py b/src/Mod/OpenSCAD/OpenSCADFeatures.py index a8cf3a5506..a3b0b306a1 100644 --- a/src/Mod/OpenSCAD/OpenSCADFeatures.py +++ b/src/Mod/OpenSCAD/OpenSCADFeatures.py @@ -431,7 +431,17 @@ class Twist: left_handed = True else: left_handed = False + auxiliary_spine = Part.makeHelix(pitch, height, radius, 0.0, left_handed) + + # OCC versions before 7.5 had a problem with using a helix as the auxilliary spine, so approximate + # it piecewise + occ_version = Part.OCC_VERSION.split(".") + if int(occ_version[0]) <= 7 and int(occ_version[1]) < 5: + num_points = int(max(3,num_revolutions * 36)) # Every ten degrees is adequate + wire = auxiliary_spine.Wires[0] + points = wire.discretize(Number=num_points) + auxiliary_spine = Part.makePolygon(points) faces = [lower_face,upper_face] for wire1,wire2 in zip(lower_face.Wires,upper_face.Wires):