Cleaned up Machine removal.
This commit is contained in:
parent
3d3a63deaf
commit
eb9e9096ce
|
@ -74,10 +74,6 @@ class CommandPathPost:
|
|||
if hasattr(obj[0], "Group") and hasattr(obj[0], "Path"):
|
||||
# # Check for a selected post post processor if it's set
|
||||
proj = obj[0]
|
||||
# postobj = None
|
||||
# for p in obj[0].Group:
|
||||
# if p.Name == "Machine":
|
||||
# postobj = p
|
||||
|
||||
if hasattr(obj[0], "PostProcessor"):
|
||||
postobj = obj[0]
|
||||
|
|
|
@ -41,8 +41,14 @@ except AttributeError:
|
|||
|
||||
|
||||
def review(obj):
|
||||
"checks the selected project for common errors"
|
||||
"checks the selected job for common errors"
|
||||
toolcontrolcount = 0
|
||||
|
||||
if len(obj.Tooltable.Tools) == 0:
|
||||
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Machine: " + str(obj.Label) + " has no tools defined in the tool table\n"))
|
||||
if obj.X_Max == obj.X_Min or obj.Y_Max == obj.Y_Min:
|
||||
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "It appears the machine limits haven't been set. Not able to check path extents.\n"))
|
||||
|
||||
for item in obj.Group:
|
||||
print "Checking: " + item.Label
|
||||
if item.Name[:2] == "TC":
|
||||
|
@ -62,13 +68,6 @@ def review(obj):
|
|||
if item.SpindleSpeed == 0:
|
||||
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Tool Controller: " + str(item.Label) + " has a 0 value for the spindle speed\n"))
|
||||
|
||||
if item.Name[:7] == "Machine":
|
||||
if len(item.Tooltable.Tools) == 0:
|
||||
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "Machine: " + str(item.Label) + " has no tools defined in the tool table\n"))
|
||||
|
||||
if item.X_Max == item.X_Min or item.Y_Max == item.Y_Min:
|
||||
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "It appears the machine limits haven't been set. Not able to check path extents.\n"))
|
||||
|
||||
if toolcontrolcount == 0:
|
||||
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "A Tool Controller was not found. Default values are used which is dangerous. Please add a Tool Controller.\n"))
|
||||
|
||||
|
|
|
@ -78,17 +78,15 @@ def export(selection,filename,argstring):
|
|||
return
|
||||
myMachine = None
|
||||
for pathobj in selection:
|
||||
if hasattr(pathobj,"Group"): #We have a compound or selection.
|
||||
for p in pathobj.Group:
|
||||
if p.Name == "Machine":
|
||||
myMachine = p
|
||||
if myMachine is None:
|
||||
if hasattr(pathobj,"MachineName"):
|
||||
myMachine = pathobj.MachineName
|
||||
if hasattr(pathobj, "MachineUnits"):
|
||||
if pathobj.MachineUnits == "Metric":
|
||||
UNITS = "G21"
|
||||
else:
|
||||
UNITS = "G20"
|
||||
if myMachine is None:
|
||||
print "No machine found in this selection"
|
||||
else:
|
||||
if myMachine.MachineUnits == "Metric":
|
||||
UNITS = "G21"
|
||||
else:
|
||||
UNITS = "G20"
|
||||
|
||||
gcode =''
|
||||
gcode+= HEADER
|
||||
|
@ -100,8 +98,7 @@ def export(selection,filename,argstring):
|
|||
|
||||
gobjects = []
|
||||
for g in selection[0].Group:
|
||||
if g.Name <>'Machine': #filtering out gcode home position from Machine object
|
||||
gobjects.append(g)
|
||||
gobjects.append(g)
|
||||
|
||||
for obj in gobjects:
|
||||
for c in obj.Path.Commands:
|
||||
|
@ -114,11 +111,11 @@ def export(selection,filename,argstring):
|
|||
outstring.append(command)
|
||||
if MODAL == True:
|
||||
if command == lastcommand:
|
||||
outstring.pop(0)
|
||||
outstring.pop(0)
|
||||
if c.Parameters >= 1:
|
||||
for param in params:
|
||||
if param in c.Parameters:
|
||||
if param == 'F':
|
||||
if param == 'F':
|
||||
outstring.append(param + PostUtils.fmt(c.Parameters['F'], FEED_DECIMALS,UNITS))
|
||||
elif param == 'H':
|
||||
outstring.append(param + str(int(c.Parameters['H'])))
|
||||
|
|
|
@ -54,7 +54,7 @@ Fix tool change
|
|||
Limit comments length and characters to Uppercase, alpha numeric and spaces add / prior to coments
|
||||
|
||||
import linuxcnc_post
|
||||
linuxcnc_post.export(object,"/path/to/file.ncc")
|
||||
linuxcnc_post.export(object,"/path/to/file.ncc","")
|
||||
'''
|
||||
|
||||
import datetime
|
||||
|
@ -110,7 +110,7 @@ if open.__module__ == '__builtin__':
|
|||
pythonopen = open
|
||||
|
||||
|
||||
def export(objectslist,filename):
|
||||
def export(objectslist,filename,argstring):
|
||||
global UNITS
|
||||
for obj in objectslist:
|
||||
if not hasattr(obj,"Path"):
|
||||
|
@ -123,19 +123,16 @@ def export(objectslist,filename):
|
|||
#Find the machine.
|
||||
#The user my have overriden post processor defaults in the GUI. Make sure we're using the current values in the Machine Def.
|
||||
myMachine = None
|
||||
for pathobj in objectslist:
|
||||
if hasattr(pathobj,"Group"): #We have a compound or project.
|
||||
for p in pathobj.Group:
|
||||
if p.Name == "Machine":
|
||||
myMachine = p
|
||||
for pathobj in selection:
|
||||
if hasattr(pathobj,"MachineName"):
|
||||
myMachine = pathobj.MachineName
|
||||
if hasattr(pathobj, "MachineUnits"):
|
||||
if pathobj.MachineUnits == "Metric":
|
||||
UNITS = "G21"
|
||||
else:
|
||||
UNITS = "G20"
|
||||
if myMachine is None:
|
||||
print "No machine found in this project"
|
||||
else:
|
||||
if myMachine.MachineUnits == "Metric":
|
||||
UNITS = "G21"
|
||||
else:
|
||||
UNITS = "G20"
|
||||
|
||||
print "No machine found in this selection"
|
||||
|
||||
# write header
|
||||
if OUTPUT_HEADER:
|
||||
|
|
|
@ -268,7 +268,7 @@ def linenumberify(GCodeString):
|
|||
result += s + "\n"
|
||||
return result
|
||||
|
||||
def export(selection,filename):
|
||||
def export(selection,filename,argstring):
|
||||
global linenr
|
||||
linenr = STARTLINENR
|
||||
lastX = 0
|
||||
|
@ -284,17 +284,15 @@ def export(selection,filename):
|
|||
return
|
||||
myMachine = None
|
||||
for pathobj in selection:
|
||||
if hasattr(pathobj,"Group"): #We have a compound or selection.
|
||||
for p in pathobj.Group:
|
||||
if p.Name == "Machine":
|
||||
myMachine = p
|
||||
if hasattr(pathobj,"MachineName"):
|
||||
myMachine = pathobj.MachineName
|
||||
if hasattr(pathobj, "MachineUnits"):
|
||||
if pathobj.MachineUnits == "Metric":
|
||||
UNITS = "G21"
|
||||
else:
|
||||
UNITS = "G20"
|
||||
if myMachine is None:
|
||||
print "No machine found in this selection"
|
||||
else:
|
||||
if myMachine.MachineUnits == "Metric":
|
||||
UNITS = "G21"
|
||||
else:
|
||||
UNITS = "G20"
|
||||
|
||||
gcode =''
|
||||
gcode+= mkHeader(selection)
|
||||
|
@ -306,8 +304,7 @@ def export(selection,filename):
|
|||
|
||||
gobjects = []
|
||||
for g in selection[0].Group:
|
||||
if g.Name <>'Machine': #filtering out gcode home position from Machine object
|
||||
gobjects.append(g)
|
||||
gobjects.append(g)
|
||||
|
||||
for obj in gobjects:
|
||||
if hasattr(obj,'GComment'):
|
||||
|
|
|
@ -30,7 +30,7 @@ in the appropriate PathScripts folder, can be used directly from inside
|
|||
FreeCAD, via the GUI importer or via python scripts with:
|
||||
|
||||
import linuxcnc_post
|
||||
linuxcnc_post.export(object,"/path/to/file.ncc")
|
||||
linuxcnc_post.export(object,"/path/to/file.ncc","")
|
||||
'''
|
||||
|
||||
TOOLTIP_ARGS='''
|
||||
|
@ -119,18 +119,16 @@ def export(objectslist, filename, argstring):
|
|||
# The user my have overriden post processor defaults in the GUI. Make
|
||||
# sure we're using the current values in the Machine Def.
|
||||
myMachine = None
|
||||
for pathobj in objectslist:
|
||||
if hasattr(pathobj, "Group"): # We have a compound or project.
|
||||
for p in pathobj.Group:
|
||||
if p.Name == "Machine":
|
||||
myMachine = p
|
||||
for pathobj in selection:
|
||||
if hasattr(pathobj,"MachineName"):
|
||||
myMachine = pathobj.MachineName
|
||||
if hasattr(pathobj, "MachineUnits"):
|
||||
if pathobj.MachineUnits == "Metric":
|
||||
UNITS = "G21"
|
||||
else:
|
||||
UNITS = "G20"
|
||||
if myMachine is None:
|
||||
print "No machine found in this project"
|
||||
else:
|
||||
if myMachine.MachineUnits == "Metric":
|
||||
UNITS = "G21"
|
||||
else:
|
||||
UNITS = "G20"
|
||||
print "No machine found in this selection"
|
||||
|
||||
# write header
|
||||
if OUTPUT_HEADER:
|
||||
|
|
Loading…
Reference in New Issue
Block a user