Fix crown gear preview mode in PartDesign Bodies
Previously, the `preview_mode` of the crown gear returned a compound of the base and the cut-outs. This caused problems in PD::Bodies where a single solid is requried. The solution in this commit changes the preview_mode to only output the base, not generating the cutout shapes at all. This is consistent with the involute gears having "simple=true" and saves again 0.5 Seconds processsing time on my system using defaults (15 teeth, 4 loft profiles). In addition, "preview = false" is also speed up by first collecting all cut-outs, and then passing them all at once to a single cut operation. This reduced the cutting time from 3.0 Seconds to 2.2 Seconds here. So preview now generats the shape immediately (0.0008s vs 0.5s) and the actual crown is generated in 2.7s instead of 3.5s (again, using the defaut parameters, measued via Python's time.perf_counter).
This commit is contained in:
@@ -422,6 +422,8 @@ class CrownGear(BaseGear):
|
||||
inner_circle.reverse()
|
||||
face = Part.Face([outer_circle, inner_circle])
|
||||
solid = face.extrude(App.Vector([0., 0., -fp.thickness.Value]))
|
||||
if fp.preview_mode:
|
||||
return solid
|
||||
|
||||
# cutting obj
|
||||
alpha_w = np.deg2rad(fp.pressure_angle.Value)
|
||||
@@ -443,17 +445,11 @@ class CrownGear(BaseGear):
|
||||
loft = makeLoft(polies, True)
|
||||
rot = App.Matrix()
|
||||
rot.rotateZ(2 * np.pi / t)
|
||||
if fp.preview_mode:
|
||||
cut_shapes = [solid]
|
||||
for _ in range(t):
|
||||
loft = loft.transformGeometry(rot)
|
||||
cut_shapes.append(loft)
|
||||
return Part.Compound(cut_shapes)
|
||||
else:
|
||||
for i in range(t):
|
||||
loft = loft.transformGeometry(rot)
|
||||
solid = solid.cut(loft)
|
||||
return solid
|
||||
cut_shapes = []
|
||||
for _ in range(t):
|
||||
loft = loft.transformGeometry(rot)
|
||||
cut_shapes.append(loft)
|
||||
return solid.cut(cut_shapes)
|
||||
|
||||
def __getstate__(self):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user