CAM: fix handling of Active state and CoolantMode with nested dressups
This commit is contained in:
@@ -118,13 +118,13 @@ def isSolid(obj):
|
||||
return not shape.isNull() and shape.Volume and shape.isClosed()
|
||||
|
||||
|
||||
def opProperty(op, prop):
|
||||
def opProperty(op, prop, default=None):
|
||||
"""opProperty(op, prop) ... return the value of property prop of the underlying operation (or None if prop does not exist)"""
|
||||
if hasattr(op, prop):
|
||||
return getattr(op, prop)
|
||||
if hasattr(op, "Base"):
|
||||
return opProperty(op.Base, prop)
|
||||
return None
|
||||
return opProperty(op.Base, prop, default)
|
||||
return default
|
||||
|
||||
|
||||
def toolControllerForOp(op):
|
||||
@@ -134,6 +134,20 @@ def toolControllerForOp(op):
|
||||
return opProperty(op, "ToolController")
|
||||
|
||||
|
||||
def coolantModeForOp(op):
|
||||
"""coolantModeForOp(op) ... return the coolant mode used by the op.
|
||||
If the op doesn't have its own coolant mode but has a Base object, return its coolant mode.
|
||||
Otherwise return "None"."""
|
||||
return opProperty(op, "CoolantMode", "None")
|
||||
|
||||
|
||||
def activeForOp(op):
|
||||
"""activeForOp(op) ... return the active property used by the op.
|
||||
If the op doesn't have its own active property but has a Base object, return its active property.
|
||||
Otherwise return True."""
|
||||
return opProperty(op, "Active", True)
|
||||
|
||||
|
||||
def getPublicObject(obj):
|
||||
"""getPublicObject(obj) ... returns the object which should be used to reference a feature of the given object."""
|
||||
if hasattr(obj, "getParentGeoFeatureGroup"):
|
||||
|
||||
@@ -32,6 +32,7 @@ import os
|
||||
from typing import Any, Dict, List
|
||||
|
||||
import FreeCAD
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Post.Utils as PostUtils
|
||||
import Path.Post.UtilsParse as PostUtilsParse
|
||||
import Path.Tool.Controller as PathToolController
|
||||
@@ -50,15 +51,6 @@ def check_canned_cycles(values: Values) -> None:
|
||||
values["SUPPRESS_COMMANDS"] += ["G99", "G98", "G80"]
|
||||
|
||||
|
||||
def determine_coolant_mode(obj) -> str:
|
||||
"""Determine the coolant mode."""
|
||||
if hasattr(obj, "CoolantMode") or hasattr(obj, "Base") and hasattr(obj.Base, "CoolantMode"):
|
||||
if hasattr(obj, "CoolantMode"):
|
||||
return obj.CoolantMode
|
||||
return obj.Base.CoolantMode
|
||||
return "None"
|
||||
|
||||
|
||||
def output_coolant_off(values: Values, gcode: Gcode, coolant_mode: str) -> None:
|
||||
"""Output the commands to turn coolant off if necessary."""
|
||||
comment: str
|
||||
@@ -314,11 +306,9 @@ def export_common(values: Values, objectslist, filename: str) -> str:
|
||||
|
||||
for obj in objectslist:
|
||||
# Skip inactive operations
|
||||
if hasattr(obj, "Active") and not obj.Active:
|
||||
if not PathUtil.activeForOp(obj):
|
||||
continue
|
||||
if hasattr(obj, "Base") and hasattr(obj.Base, "Active") and not obj.Base.Active:
|
||||
continue
|
||||
coolant_mode = determine_coolant_mode(obj)
|
||||
coolant_mode = PathUtil.coolantModeForOp(obj)
|
||||
output_start_bcnc(values, gcode, obj)
|
||||
output_preop(values, gcode, obj)
|
||||
output_coolant_on(values, gcode, coolant_mode)
|
||||
|
||||
@@ -31,6 +31,7 @@ from typing import Any, List, Tuple
|
||||
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Path.Base.Util as PathUtil
|
||||
import Path.Post.Processor
|
||||
import Path.Post.UtilsArguments
|
||||
import Path.Post.UtilsExport
|
||||
@@ -773,11 +774,9 @@ class Snapmaker(Path.Post.Processor.PostProcessor):
|
||||
|
||||
for obj in objects:
|
||||
# Skip inactive operations
|
||||
if hasattr(obj, "Active") and not obj.Active:
|
||||
if not PathUtil.activeForOp(obj):
|
||||
continue
|
||||
if hasattr(obj, "Base") and hasattr(obj.Base, "Active") and not obj.Base.Active:
|
||||
continue
|
||||
coolant_mode = Path.Post.UtilsExport.determine_coolant_mode(obj)
|
||||
coolant_mode = PathUtil.coolantModeForOp(obj)
|
||||
Path.Post.UtilsExport.output_start_bcnc(self.values, gcode, obj)
|
||||
Path.Post.UtilsExport.output_preop(self.values, gcode, obj)
|
||||
Path.Post.UtilsExport.output_coolant_on(self.values, gcode, coolant_mode)
|
||||
|
||||
Reference in New Issue
Block a user