Toolchange generator

This commit is contained in:
sliptonic
2022-01-29 15:48:50 -06:00
parent 00319582e3
commit 0be2903aca
5 changed files with 176 additions and 18 deletions

View File

@@ -28,6 +28,8 @@ import Path
import PathScripts.PathLog as PathLog
import PathScripts.PathPreferences as PathPreferences
import PathScripts.PathToolBit as PathToolBit
from Generators import toolchange_generator as toolchange_generator
from Generators.toolchange_generator import SpindleDirection
if False:
@@ -259,27 +261,28 @@ class ToolController:
def execute(self, obj):
PathLog.track()
commands = ""
commands += "(" + obj.Label + ")" + "\n"
commands += "M6 T" + str(obj.ToolNumber) + "\n"
args = {
"toolnumber": obj.ToolNumber,
"toollabel": obj.Label,
"spindlespeed": obj.SpindleSpeed,
"spindledirection": SpindleDirection.OFF,
}
# If a toolbit is used, check to see if spindlepower is allowed.
# This is to prevent accidentally spinning the spindle with an
# unpowered tool like probe or dragknife
allowSpindlePower = True
if not isinstance(obj.Tool, Path.Tool) and hasattr(obj.Tool, "SpindlePower"):
allowSpindlePower = obj.Tool.SpindlePower
if allowSpindlePower:
PathLog.debug("selected tool preventing spindle power")
if obj.SpindleDir == "Forward":
commands += "M3 S" + str(obj.SpindleSpeed) + "\n"
if hasattr(obj.Tool, "SpindlePower"):
if not obj.Tool.SpindlePower:
args["spindledirection"] = SpindleDirection.OFF
else:
commands += "M4 S" + str(obj.SpindleSpeed) + "\n"
if obj.SpindleDir == "Forward":
args["spindledirection"] = SpindleDirection.CW
else:
args["spindledirection"] = SpindleDirection.CCW
else:
if obj.SpindleDir == "Forward":
args["spindledirection"] = SpindleDirection.CW
else:
args["spindledirection"] = SpindleDirection.CCW
if commands == "":
commands += "(No commands processed)"
commands = toolchange_generator.generate(**args)
path = Path.Path(commands)
obj.Path = path