Skip to content

Commit

Permalink
Fixes for various gcode errors
Browse files Browse the repository at this point in the history
Some operations were still outputting even if disabled.
Nested comments caused trouble in linuxcnc
Machine was producing an initial move that was potentially dangerous
  • Loading branch information
sliptonic committed Jun 11, 2016
1 parent f55fb8c commit dff173c
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 29 deletions.
25 changes: 20 additions & 5 deletions src/Mod/Path/PathScripts/PathDrilling.py
Expand Up @@ -79,10 +79,13 @@ def __setstate__(self, state):

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
Expand All @@ -100,9 +103,9 @@ def execute(self, obj):
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"
Expand Down Expand Up @@ -155,8 +158,20 @@ def execute(self, obj):

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"
Expand Down
22 changes: 17 additions & 5 deletions src/Mod/Path/PathScripts/PathEngrave.py
Expand Up @@ -81,10 +81,12 @@ def __setstate__(self, state):

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:
Expand All @@ -102,9 +104,9 @@ def execute(self, obj):
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:
Expand All @@ -118,8 +120,18 @@ def execute(self, obj):
# 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
Expand Down
5 changes: 3 additions & 2 deletions src/Mod/Path/PathScripts/PathMachine.py
Expand Up @@ -73,8 +73,9 @@ def __init__(self, obj):
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):
Expand Down
9 changes: 6 additions & 3 deletions src/Mod/Path/PathScripts/PathPocket.py
Expand Up @@ -111,7 +111,7 @@ def onChanged(self, obj, prop):
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):
Expand Down Expand Up @@ -233,6 +233,9 @@ def buildpathocc(self, obj, shape):

# 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)
Expand Down Expand Up @@ -374,9 +377,9 @@ def execute(self, obj):
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:
Expand Down
11 changes: 7 additions & 4 deletions src/Mod/Path/PathScripts/PathProfile.py
Expand Up @@ -127,7 +127,7 @@ def __setstate__(self, state):

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
Expand Down Expand Up @@ -171,7 +171,8 @@ def addprofilebase(self, obj, ss, sub=""):
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
Expand All @@ -194,6 +195,8 @@ def _buildPathLibarea(self, obj, edgelist):
import math
import area
output = ""
if obj.Comment != "":
output += '(' + str(obj.Comment)+')\n'

if obj.StartPoint and obj.UseStartPoint:
startpoint = obj.StartPoint
Expand Down Expand Up @@ -280,9 +283,9 @@ def execute(self, obj):
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:
Expand Down
20 changes: 15 additions & 5 deletions src/Mod/Path/PathScripts/PathRemote.py
Expand Up @@ -157,10 +157,12 @@ def onChanged(self, obj, prop):
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:
Expand All @@ -178,13 +180,21 @@ def execute(self, obj):
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:
Expand Down
18 changes: 13 additions & 5 deletions src/Mod/Path/PathScripts/PathSurface.py
Expand Up @@ -121,7 +121,7 @@ def __setstate__(self, state):

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
Expand Down Expand Up @@ -258,6 +258,8 @@ def execute(self, obj):
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:
Expand All @@ -275,9 +277,9 @@ def execute(self, obj):
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:
Expand Down Expand Up @@ -312,9 +314,15 @@ def execute(self, obj):
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:

Expand Down

0 comments on commit dff173c

Please sign in to comment.