From dff173cd1fd53f9bae15b6377b48d63f36e228a7 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Wed, 8 Jun 2016 08:57:36 -0500 Subject: [PATCH] Fixes for various gcode errors Some operations were still outputting even if disabled. Nested comments caused trouble in linuxcnc Machine was producing an initial move that was potentially dangerous --- src/Mod/Path/PathScripts/PathDrilling.py | 25 +++++++++++++++++++----- src/Mod/Path/PathScripts/PathEngrave.py | 22 ++++++++++++++++----- src/Mod/Path/PathScripts/PathMachine.py | 5 +++-- src/Mod/Path/PathScripts/PathPocket.py | 9 ++++++--- src/Mod/Path/PathScripts/PathProfile.py | 11 +++++++---- src/Mod/Path/PathScripts/PathRemote.py | 20 ++++++++++++++----- src/Mod/Path/PathScripts/PathSurface.py | 18 ++++++++++++----- 7 files changed, 81 insertions(+), 29 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathDrilling.py b/src/Mod/Path/PathScripts/PathDrilling.py index 98c8bb125..3348641cc 100644 --- a/src/Mod/Path/PathScripts/PathDrilling.py +++ b/src/Mod/Path/PathScripts/PathDrilling.py @@ -79,10 +79,13 @@ class ObjectDrilling: def onChanged(self, obj, prop): if prop == "UserLabel": - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription def execute(self, obj): output = "" + if obj.Comment != "": + output += '(' + str(obj.Comment)+')\n' + toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: self.vertFeed = 100 @@ -100,9 +103,9 @@ class ObjectDrilling: obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": - obj.Label = obj.Name + " (" + obj.ToolDescription + ")" + obj.Label = obj.Name + " :" + obj.ToolDescription else: - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription locations = [] output = "(Begin Drilling)\n" @@ -155,8 +158,20 @@ class ObjectDrilling: output += "G80\n" - path = Path.Path(output) - obj.Path = path +# path = Path.Path(output) +# obj.Path = path + + if obj.Active: + path = Path.Path(output) + obj.Path = path + obj.ViewObject.Visibility = True + + else: + path = Path.Path("(inactive operation)") + obj.Path = path + obj.ViewObject.Visibility = False + + def checkdrillable(self, obj, sub): print "in checkdrillable" diff --git a/src/Mod/Path/PathScripts/PathEngrave.py b/src/Mod/Path/PathScripts/PathEngrave.py index 002721233..92be77a6d 100644 --- a/src/Mod/Path/PathScripts/PathEngrave.py +++ b/src/Mod/Path/PathScripts/PathEngrave.py @@ -81,10 +81,12 @@ class ObjectPathEngrave: def onChanged(self, obj, prop): if prop == "UserLabel": - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription def execute(self, obj): output = "" + if obj.Comment != "": + output += '(' + str(obj.Comment)+')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: @@ -102,9 +104,9 @@ class ObjectPathEngrave: obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": - obj.Label = obj.Name + " (" + obj.ToolDescription + ")" + obj.Label = obj.Name + " :" + obj.ToolDescription else: - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription if obj.Base: for o in obj.Base: @@ -118,8 +120,18 @@ class ObjectPathEngrave: # print output if output == "": output += "G0" - path = Path.Path(output) - obj.Path = path + + if obj.Active: + path = Path.Path(output) + obj.Path = path + obj.ViewObject.Visibility = True + + else: + path = Path.Path("(inactive operation)") + obj.Path = path + obj.ViewObject.Visibility = False + # path = Path.Path(output) + # obj.Path = path def buildpathocc(self, obj, wires): import Part diff --git a/src/Mod/Path/PathScripts/PathMachine.py b/src/Mod/Path/PathScripts/PathMachine.py index 563c91438..ff56c5874 100644 --- a/src/Mod/Path/PathScripts/PathMachine.py +++ b/src/Mod/Path/PathScripts/PathMachine.py @@ -73,8 +73,9 @@ class Machine: def execute(self, obj): obj.Label = "Machine_" + str(obj.MachineName) # need to filter this path out in post- only for visualization - gcode = 'G0 X' + str(obj.X.Value) + ' Y' + \ - str(obj.Y.Value) + ' Z' + str(obj.Z.Value) + #gcode = 'G0 X' + str(obj.X.Value) + ' Y' + \ + # str(obj.Y.Value) + ' Z' + str(obj.Z.Value) + gcode = '(' + str(obj.Label) + ')' obj.Path = Path.Path(gcode) def onChanged(self, obj, prop): diff --git a/src/Mod/Path/PathScripts/PathPocket.py b/src/Mod/Path/PathScripts/PathPocket.py index 7503ace67..1063c754a 100644 --- a/src/Mod/Path/PathScripts/PathPocket.py +++ b/src/Mod/Path/PathScripts/PathPocket.py @@ -111,7 +111,7 @@ class ObjectPocket: obj.setEditorMode('RampSize', 2) # make this hidden if prop == "UserLabel": - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription def __getstate__(self): @@ -233,6 +233,9 @@ class ObjectPocket: # Build up the offset loops output = "" + if obj.Comment != "": + output += '(' + str(obj.Comment)+')\n' + offsets = [] nextradius = (self.radius * 2) * (float(obj.StepOver)/100) result = DraftGeomUtils.pocket2d(shape, nextradius) @@ -374,9 +377,9 @@ class ObjectPocket: obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": - obj.Label = obj.Name + " (" + obj.ToolDescription + ")" + obj.Label = obj.Name + " :" + obj.ToolDescription else: - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription if obj.Base: for b in obj.Base: diff --git a/src/Mod/Path/PathScripts/PathProfile.py b/src/Mod/Path/PathScripts/PathProfile.py index b1d397458..e6ec23500 100644 --- a/src/Mod/Path/PathScripts/PathProfile.py +++ b/src/Mod/Path/PathScripts/PathProfile.py @@ -127,7 +127,7 @@ class ObjectProfile: def onChanged(self, obj, prop): if prop == "UserLabel": - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription def addprofilebase(self, obj, ss, sub=""): baselist = obj.Base @@ -171,7 +171,8 @@ class ObjectProfile: def _buildPathOCC(self, obj, wire): import DraftGeomUtils output = "" - output += '(' + str(obj.Comment)+')\n' + if obj.Comment != "": + output += '(' + str(obj.Comment)+')\n' if obj.Direction == 'CCW': clockwise = False @@ -194,6 +195,8 @@ class ObjectProfile: import math import area output = "" + if obj.Comment != "": + output += '(' + str(obj.Comment)+')\n' if obj.StartPoint and obj.UseStartPoint: startpoint = obj.StartPoint @@ -280,9 +283,9 @@ print "y - " + str(point.y) obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": - obj.Label = obj.Name + " (" + obj.ToolDescription + ")" + obj.Label = obj.Name + " :" + obj.ToolDescription else: - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription if obj.Base: diff --git a/src/Mod/Path/PathScripts/PathRemote.py b/src/Mod/Path/PathScripts/PathRemote.py index 9bbe1dbc1..11f4bc87e 100644 --- a/src/Mod/Path/PathScripts/PathRemote.py +++ b/src/Mod/Path/PathScripts/PathRemote.py @@ -157,10 +157,12 @@ class ObjectRemote: obj.proplist = pl if prop == "UserLabel": - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription def execute(self, obj): output = "" + if obj.Comment != "": + output += '(' + str(obj.Comment)+')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: @@ -178,13 +180,21 @@ class ObjectRemote: obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": - obj.Label = obj.Name + " (" + obj.ToolDescription + ")" + obj.Label = obj.Name + " :" + obj.ToolDescription else: - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription output += "(remote gcode goes here)" - path = Path.Path(output) - obj.Path = path + + if obj.Active: + path = Path.Path(output) + obj.Path = path + obj.ViewObject.Visibility = True + + else: + path = Path.Path("(inactive operation)") + obj.Path = path + obj.ViewObject.Visibility = False class ViewProviderRemote: diff --git a/src/Mod/Path/PathScripts/PathSurface.py b/src/Mod/Path/PathScripts/PathSurface.py index 2ea1f4f01..b7f98219f 100644 --- a/src/Mod/Path/PathScripts/PathSurface.py +++ b/src/Mod/Path/PathScripts/PathSurface.py @@ -121,7 +121,7 @@ class ObjectSurface: def onChanged(self, obj, prop): if prop == "UserLabel": - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription def _waterline(self, obj, s, bb): import ocl @@ -258,6 +258,8 @@ class ObjectSurface: FreeCAD.Console.PrintWarning( translate("PathSurface", "Hold on. This might take a minute.\n")) output = "" + if obj.Comment != "": + output += '(' + str(obj.Comment)+')\n' toolLoad = PathUtils.getLastToolLoad(obj) if toolLoad is None or toolLoad.ToolNumber == 0: @@ -275,9 +277,9 @@ class ObjectSurface: obj.ToolDescription = toolLoad.Name if obj.UserLabel == "": - obj.Label = obj.Name + " (" + obj.ToolDescription + ")" + obj.Label = obj.Name + " :" + obj.ToolDescription else: - obj.Label = obj.UserLabel + " (" + obj.ToolDescription + ")" + obj.Label = obj.UserLabel + " :" + obj.ToolDescription if obj.Base: for b in obj.Base: @@ -312,9 +314,15 @@ class ObjectSurface: elif obj.Algorithm == 'OCL Waterline': output = self._waterline(obj, s, bb) - path = Path.Path(output) - obj.Path = path + if obj.Active: + path = Path.Path(output) + obj.Path = path + obj.ViewObject.Visibility = True + else: + path = Path.Path("(inactive operation)") + obj.Path = path + obj.ViewObject.Visibility = False class ViewProviderSurface: