Update Path to py3-compatible printing

This commit is contained in:
Kurt Kremitzki 2017-01-29 22:11:45 -06:00 committed by looooo
parent 32bacd0b63
commit e47edae9c3
23 changed files with 92 additions and 77 deletions

View File

@ -20,6 +20,7 @@
# * USA * # * USA *
# * * # * *
# *************************************************************************** # ***************************************************************************
from __future__ import print_function
import FreeCAD import FreeCAD
import FreeCADGui import FreeCADGui
@ -57,7 +58,7 @@ class ObjectCompoundExtended:
def onChanged(self, obj, prop): def onChanged(self, obj, prop):
if prop == "Group": if prop == "Group":
print 'check order' print('check order')
for child in obj.Group: for child in obj.Group:
if child.isDerivedFrom("Path::Feature"): if child.isDerivedFrom("Path::Feature"):
child.touch() child.touch()

View File

@ -21,6 +21,7 @@
# * USA * # * USA *
# * * # * *
# *************************************************************************** # ***************************************************************************
from __future__ import print_function
import FreeCAD import FreeCAD
import FreeCADGui import FreeCADGui
import Path import Path
@ -90,7 +91,7 @@ class ViewProviderDressup:
if g.Name == self.Object.Base.Name: if g.Name == self.Object.Base.Name:
group.remove(g) group.remove(g)
i.Group = group i.Group = group
print i.Group print(i.Group)
return [self.Object.Base] return [self.Object.Base]
def __getstate__(self): def __getstate__(self):

View File

@ -21,6 +21,7 @@
# * USA * # * USA *
# * * # * *
# *************************************************************************** # ***************************************************************************
from __future__ import print_function
import DraftGeomUtils import DraftGeomUtils
import FreeCAD import FreeCAD
import FreeCADGui import FreeCADGui
@ -951,7 +952,7 @@ class ViewProviderDressup:
if g.Name == self.Object.Base.Name: if g.Name == self.Object.Base.Name:
group.remove(g) group.remove(g)
i.Group = group i.Group = group
print i.Group print(i.Group)
#FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False #FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False
return [self.Object.Base] return [self.Object.Base]

View File

@ -22,6 +22,7 @@
# * * # * *
# *************************************************************************** # ***************************************************************************
from __future__ import print_function
import FreeCAD import FreeCAD
import FreeCADGui import FreeCADGui
import Path import Path
@ -451,7 +452,7 @@ class ViewProviderDressup:
if g.Name == self.Object.Base.Name: if g.Name == self.Object.Base.Name:
group.remove(g) group.remove(g)
i.Group = group i.Group = group
print i.Group print(i.Group)
#FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False #FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False
return [self.Object.Base] return [self.Object.Base]

View File

@ -22,6 +22,7 @@
# * * # * *
# *************************************************************************** # ***************************************************************************
from __future__ import print_function
import FreeCAD import FreeCAD
import Path import Path
import Part import Part
@ -304,7 +305,7 @@ class ObjectDrilling:
else: else:
baselist.append(item) baselist.append(item)
print baselist print(baselist)
obj.Base = baselist obj.Base = baselist
self.execute(obj) self.execute(obj)

View File

@ -22,6 +22,7 @@
# * * # * *
# *************************************************************************** # ***************************************************************************
'''PathKurveUtils - functions needed for using libarea (created by Dan Heeks) for making simple CNC profile paths ''' '''PathKurveUtils - functions needed for using libarea (created by Dan Heeks) for making simple CNC profile paths '''
from __future__ import print_function
import Part import Part
import math import math
import area import area
@ -142,7 +143,7 @@ def profile(curve, side_of_line, radius=1.0, vertfeed=0.0, horizfeed=0.0, offset
output = "" output = ""
output += "G0 Z" + str(clearance) + "\n" output += "G0 Z" + str(clearance) + "\n"
print "in profile: 151" print("in profile: 151")
offset_curve = area.Curve(curve) offset_curve = area.Curve(curve)
if offset_curve.getNumVertices() <= 1: if offset_curve.getNumVertices() <= 1:
raise Exception, "Sketch has no elements!" raise Exception, "Sketch has no elements!"
@ -338,10 +339,10 @@ def profile2(curve, direction="on", radius=1.0, vertfeed=0.0,
using_area_for_offset = True using_area_for_offset = True
a = area.Area() a = area.Area()
a.append(curve) a.append(curve)
print "curve, offset: " , str(curve), str(offset) print("curve, offset: " , str(curve), str(offset))
a.Offset(-offset) a.Offset(-offset)
for curve in a.getCurves(): for curve in a.getCurves():
print "result curve: ", curve print("result curve: ", curve)
curve_cw = curve.IsClockwise() curve_cw = curve.IsClockwise()
if cw != curve_cw: if cw != curve_cw:
curve.Reverse() curve.Reverse()

View File

@ -22,6 +22,7 @@
# * * # * *
# *************************************************************************** # ***************************************************************************
from __future__ import print_function
import FreeCAD import FreeCAD
import Path import Path
from PySide import QtCore, QtGui from PySide import QtCore, QtGui
@ -211,7 +212,7 @@ class ObjectFace:
# To reload this from FreeCAD, use: import PathScripts.PathFace; reload(PathScripts.PathFace) # To reload this from FreeCAD, use: import PathScripts.PathFace; reload(PathScripts.PathFace)
def execute(self, obj): def execute(self, obj):
print "in execute" print("in execute")
if not obj.Active: if not obj.Active:
path = Path.Path("(inactive operation)") path = Path.Path("(inactive operation)")
@ -260,7 +261,7 @@ class ObjectFace:
if isinstance (shape, Part.Face): if isinstance (shape, Part.Face):
faces.append(shape) faces.append(shape)
else: else:
print ('falling out') print('falling out')
return return
planeshape = Part.makeCompound(faces) planeshape = Part.makeCompound(faces)

View File

@ -154,7 +154,7 @@ class ObjectPocket:
else: else:
baselist.append(item) baselist.append(item)
obj.Base = baselist obj.Base = baselist
print "this base is: " + str(baselist) print("this base is: " + str(baselist))
self.execute(obj) self.execute(obj)
def getStock(self, obj): def getStock(self, obj):
@ -316,7 +316,7 @@ class ObjectPocket:
# Otherwise, straight plunge... Don't want to, but sometimes you might not have a choice. # Otherwise, straight plunge... Don't want to, but sometimes you might not have a choice.
# FIXME: At least not with the lazy ramp programming above... # FIXME: At least not with the lazy ramp programming above...
else: else:
print "WARNING: Straight-plunging... probably not good, but we didn't find a place to helix or ramp" print("WARNING: Straight-plunging... probably not good, but we didn't find a place to helix or ramp")
startPoint = edge.Vertexes[0].Point startPoint = edge.Vertexes[0].Point
output += "G0 Z" + fmt(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n" output += "G0 Z" + fmt(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n"
output += "G0 X" + fmt(startPoint.x) + " Y" + fmt(startPoint.y) +\ output += "G0 X" + fmt(startPoint.x) + " Y" + fmt(startPoint.y) +\

View File

@ -22,6 +22,7 @@
# * * # * *
# *************************************************************************** # ***************************************************************************
''' Post Process command that will make use of the Output File and Post Processor entries in PathJob ''' ''' Post Process command that will make use of the Output File and Post Processor entries in PathJob '''
from __future__ import print_function
import FreeCAD import FreeCAD
import FreeCADGui import FreeCADGui
from PySide import QtCore, QtGui from PySide import QtCore, QtGui
@ -190,7 +191,7 @@ class CommandPathPost:
FreeCADGui.addModule("PathScripts.PathPost") FreeCADGui.addModule("PathScripts.PathPost")
# select the Path Job that you want to post output from # select the Path Job that you want to post output from
selected = FreeCADGui.Selection.getCompleteSelection() selected = FreeCADGui.Selection.getCompleteSelection()
print "in activated %s" %(selected) print("in activated %s" %(selected))
# try to find the job, if it's not directly selected ... # try to find the job, if it's not directly selected ...
jobs = set() jobs = set()

View File

@ -35,12 +35,12 @@ class PostProcessor:
def load(cls, processor): def load(cls, processor):
postname = processor + "_post" postname = processor + "_post"
exec "import %s as current_post" % postname exec("import %s as current_post" % postname)
# make sure the script is reloaded if it was previously loaded # make sure the script is reloaded if it was previously loaded
# should the script have been imported for the first time above # should the script have been imported for the first time above
# then the initialization code of the script gets executed twice # then the initialization code of the script gets executed twice
# resulting in 2 load messages if the script outputs one of those. # resulting in 2 load messages if the script outputs one of those.
exec "reload(%s)" % 'current_post' exec("reload(%s)" % 'current_post')
instance = PostProcessor(current_post) instance = PostProcessor(current_post)
instance.units = None instance.units = None

View File

@ -165,8 +165,8 @@ class ObjectProfile:
curve = PathKurveUtils.makeAreaCurve(edgelist, obj.Direction, startpoint, endpoint) curve = PathKurveUtils.makeAreaCurve(edgelist, obj.Direction, startpoint, endpoint)
'''The following line uses a profile function written for use with FreeCAD. It's clean but incomplete. It doesn't handle '''The following line uses a profile function written for use with FreeCAD. It's clean but incomplete. It doesn't handle
print "x = " + str(point.x) print("x = " + str(point.x))
print "y - " + str(point.y) print("y - " + str(point.y))
holding tags holding tags
start location start location
CRC CRC

View File

@ -25,6 +25,7 @@
Path projects. Ideally, the user could execute these utilities from an icon Path projects. Ideally, the user could execute these utilities from an icon
to make sure tools are selected and configured and defaults have been revised''' to make sure tools are selected and configured and defaults have been revised'''
from __future__ import print_function
from PySide import QtCore, QtGui from PySide import QtCore, QtGui
import FreeCAD import FreeCAD
import FreeCADGui import FreeCADGui
@ -50,7 +51,7 @@ def review(obj):
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "It appears the machine limits haven't been set. Not able to check path extents.\n")) 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: for item in obj.Group:
print "Checking: " + item.Label print("Checking: " + item.Label)
if item.Name[:2] == "TC": if item.Name[:2] == "TC":
toolcontrolcount += 1 toolcontrolcount += 1
if item.ToolNumber == 0: if item.ToolNumber == 0:

View File

@ -22,6 +22,7 @@
# * * # * *
# *************************************************************************** # ***************************************************************************
from __future__ import print_function
import FreeCAD import FreeCAD
import Path import Path
from PathScripts import PathUtils from PathScripts import PathUtils
@ -145,7 +146,7 @@ class ObjectSurface:
str(fmt(p.x)) + " Y" + str(fmt(p.y)) + \ str(fmt(p.x)) + " Y" + str(fmt(p.y)) + \
" Z" + str(fmt(zheight)) + "\n" " Z" + str(fmt(zheight)) + "\n"
loopstring += "(loop end)" + "\n" loopstring += "(loop end)" + "\n"
print " loop ", nloop, " with ", len(loop), " points" print(" loop ", nloop, " with ", len(loop), " points")
nloop = nloop + 1 nloop = nloop + 1
waterlinestring += loopstring waterlinestring += loopstring
waterlinestring += "(waterline end)" + "\n" waterlinestring += "(waterline end)" + "\n"
@ -174,7 +175,7 @@ class ObjectSurface:
# (see c++ code) # (see c++ code)
all_loops = [] all_loops = []
for zh in zheights: for zh in zheights:
print "calculating Waterline at z= ", zh print("calculating Waterline at z= ", zh)
wl.reset() wl.reset()
wl.setZ(zh) # height for this waterline wl.setZ(zh) # height for this waterline
wl.run() wl.run()
@ -184,10 +185,10 @@ class ObjectSurface:
n = 0 n = 0
output = "" output = ""
for loops in all_loops: # at each z-height, we may get many loops for loops in all_loops: # at each z-height, we may get many loops
print " %d/%d:" % (n, len(all_loops)) print(" %d/%d:" % (n, len(all_loops)))
output += drawLoops(loops) output += drawLoops(loops)
n = n + 1 n = n + 1
print "(" + str(calctime) + ")" print("(" + str(calctime) + ")")
return output return output
def _dropcutter(self, obj, s, bb): def _dropcutter(self, obj, s, bb):
@ -231,11 +232,11 @@ class ObjectSurface:
t_before = time.time() t_before = time.time()
pdc.run() pdc.run()
t_after = time.time() t_after = time.time()
print "calculation took ", t_after - t_before, " s" print("calculation took ", t_after - t_before, " s")
# retrieve the points # retrieve the points
clp = pdc.getCLPoints() clp = pdc.getCLPoints()
print "points received: " + str(len(clp)) print("points received: " + str(len(clp)))
# generate the path commands # generate the path commands
output = "" output = ""
@ -296,7 +297,7 @@ class ObjectSurface:
mesh = parentJob.Base mesh = parentJob.Base
if mesh is None: if mesh is None:
return return
print "base object: " + mesh.Name print("base object: " + mesh.Name)
@ -499,13 +500,13 @@ class TaskPanel:
# get type of object # get type of object
if sel.TypeId.startswith('Mesh'): if sel.TypeId.startswith('Mesh'):
# it is a mesh already # it is a mesh already
print 'was already mesh' print('was already mesh')
elif sel.TypeId.startswith('Part') and \ elif sel.TypeId.startswith('Part') and \
(sel.Shape.BoundBox.XLength > 0) and \ (sel.Shape.BoundBox.XLength > 0) and \
(sel.Shape.BoundBox.YLength > 0) and \ (sel.Shape.BoundBox.YLength > 0) and \
(sel.Shape.BoundBox.ZLength > 0): (sel.Shape.BoundBox.ZLength > 0):
print 'this is a solid Part object' print('this is a solid Part object')
else: else:
FreeCAD.Console.PrintError( FreeCAD.Console.PrintError(

View File

@ -22,6 +22,7 @@
# * * # * *
# *************************************************************************** # ***************************************************************************
from __future__ import print_function
import FreeCAD import FreeCAD
import xml.sax import xml.sax
import FreeCADGui import FreeCADGui
@ -254,8 +255,8 @@ class ToolLibraryManager():
if listname == "<Main>": if listname == "<Main>":
self.saveMainLibrary(tt) self.saveMainLibrary(tt)
return True return True
except Exception, e: except Exception as e:
print "could not parse file", e print("could not parse file", e)
def write(self, filename, listname): def write(self, filename, listname):
"exports the tooltable to a file" "exports the tooltable to a file"
@ -266,14 +267,14 @@ class ToolLibraryManager():
file.write('<?xml version="1.0" encoding="UTF-8"?>\n') file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
file.write(tt.Content) file.write(tt.Content)
file.close() file.close()
print "Written ", unicode(filename[0]) print("Written ", unicode(filename[0]))
except Exception, e: except Exception as e:
print "Could not write file:", e print("Could not write file:", e)
def addnew(self, listname, tool, position = None): def addnew(self, listname, tool, position = None):
"adds a new tool at the end of the table" "adds a new tool at the end of the table"
print listname, tool, position print(listname, tool, position)
tt = self._findList(listname) tt = self._findList(listname)
if position is None: if position is None:
tt.addTools(tool) tt.addTools(tool)
@ -413,7 +414,7 @@ class EditorPanel():
def addTool(self): def addTool(self):
t = Path.Tool() t = Path.Tool()
print ("adding a new tool") print("adding a new tool")
editform = FreeCADGui.PySideUic.loadUi(":/panels/ToolEdit.ui") editform = FreeCADGui.PySideUic.loadUi(":/panels/ToolEdit.ui")
r = editform.exec_() r = editform.exec_()

View File

@ -620,7 +620,7 @@ def addToJob(obj, jobname = None):
if r is False: if r is False:
return None return None
else: else:
print form.cboProject.currentText() print(form.cboProject.currentText())
job = [i for i in jobs if i.Name == form.cboProject.currentText()][0] job = [i for i in jobs if i.Name == form.cboProject.currentText()][0]
g = job.Group g = job.Group
@ -690,7 +690,7 @@ def arc(cx, cy, sx, sy, ex, ey, horizFeed=0, ez=None, ccw=False):
eps = 0.01 eps = 0.01
if (math.sqrt((cx - sx)**2 + (cy - sy)**2) - math.sqrt((cx - ex)**2 + (cy - ey)**2)) >= eps: if (math.sqrt((cx - sx)**2 + (cy - sy)**2) - math.sqrt((cx - ex)**2 + (cy - ey)**2)) >= eps:
print "ERROR: Illegal arc: Start and end radii not equal" print("ERROR: Illegal arc: Start and end radii not equal")
return "" return ""
retstr = "" retstr = ""

View File

@ -21,6 +21,7 @@
#* USA * #* USA *
#* * #* *
#*************************************************************************** #***************************************************************************
from __future__ import print_function
TOOLTIP=''' example post for Centroid CNC mill''' TOOLTIP=''' example post for Centroid CNC mill'''
import FreeCAD import FreeCAD
@ -85,7 +86,7 @@ def export(selection,filename,argstring):
else: else:
UNITS = "G20" UNITS = "G20"
if myMachine is None: if myMachine is None:
print "No machine found in this selection" print("No machine found in this selection")
gcode ='' gcode =''
gcode+= HEADER % (FreeCAD.ActiveDocument.FileName) gcode+= HEADER % (FreeCAD.ActiveDocument.FileName)

View File

@ -20,7 +20,7 @@
# * USA * # * USA *
# * * # * *
# ***************************************************************************/ # ***************************************************************************/
from __future__ import print_function
TOOLTIP=''' TOOLTIP='''
Dumper is an extremely simple postprocessor file for the Path workbench. It is used Dumper is an extremely simple postprocessor file for the Path workbench. It is used
@ -52,9 +52,9 @@ def export(objectslist, filename,argstring):
for obj in objectslist: for obj in objectslist:
if not hasattr(obj, "Path"): if not hasattr(obj, "Path"):
print "the object " + obj.Name + " is not a path. Please select only path and Compounds." print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
return return
print "postprocessing..." print("postprocessing...")
output += parse(obj) output += parse(obj)
if SHOW_EDITOR: if SHOW_EDITOR:
@ -68,7 +68,7 @@ def export(objectslist, filename,argstring):
else: else:
final = output final = output
print "done postprocessing." print("done postprocessing.")
def parse(pathobj): def parse(pathobj):
@ -90,4 +90,4 @@ def parse(pathobj):
out += str(c) + "\n" out += str(c) + "\n"
return out return out
print __name__ + " gcode postprocessor loaded." print(__name__ + " gcode postprocessor loaded.")

View File

@ -24,7 +24,7 @@
#* (c) Linden (Linden@aktfast.net) 2016 * #* (c) Linden (Linden@aktfast.net) 2016 *
#* * #* *
#***************************************************************************/ #***************************************************************************/
from __future__ import print_function
TOOLTIP=''' TOOLTIP='''
This is a postprocessor file for the Path workbench. It is used to This is a postprocessor file for the Path workbench. It is used to
@ -114,10 +114,10 @@ def export(objectslist,filename,argstring):
global UNITS global UNITS
for obj in objectslist: for obj in objectslist:
if not hasattr(obj,"Path"): if not hasattr(obj,"Path"):
print "the object " + obj.Name + " is not a path. Please select only path and Compounds." print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
return return
print "postprocessing..." print("postprocessing...")
gcode = "" gcode = ""
#Find the machine. #Find the machine.
@ -132,7 +132,7 @@ def export(objectslist,filename,argstring):
else: else:
UNITS = "G20" UNITS = "G20"
if myMachine is None: if myMachine is None:
print "No machine found in this selection" print("No machine found in this selection")
# write header # write header
if OUTPUT_HEADER: if OUTPUT_HEADER:
@ -177,7 +177,7 @@ def export(objectslist,filename,argstring):
else: else:
final = gcode final = gcode
print "done postprocessing." print("done postprocessing.")
gfile = pythonopen(filename,"wb") gfile = pythonopen(filename,"wb")
gfile.write(gcode) gfile.write(gcode)
@ -259,5 +259,5 @@ def parse(pathobj):
return out return out
print __name__ + " gcode postprocessor loaded." print(__name__ + " gcode postprocessor loaded.")

View File

@ -20,7 +20,7 @@
# * USA * # * USA *
# * * # * *
# ***************************************************************************/ # ***************************************************************************/
from __future__ import print_function
TOOLTIP=''' TOOLTIP='''
This is an example postprocessor file for the Path workbench. It is used This is an example postprocessor file for the Path workbench. It is used
@ -42,11 +42,11 @@ if open.__module__ == '__builtin__':
def export(objectslist, filename,argstring): def export(objectslist, filename,argstring):
"called when freecad exports a list of objects" "called when freecad exports a list of objects"
if len(objectslist) > 1: if len(objectslist) > 1:
print "This script is unable to write more than one Path object" print("This script is unable to write more than one Path object")
return return
obj = objectslist[0] obj = objectslist[0]
if not hasattr(obj, "Path"): if not hasattr(obj, "Path"):
print "the given object is not a path" print("the given object is not a path")
gcode = obj.Path.toGCode() gcode = obj.Path.toGCode()
gcode = parse(gcode) gcode = parse(gcode)
gfile = pythonopen(filename, "wb") gfile = pythonopen(filename, "wb")
@ -56,7 +56,7 @@ def export(objectslist, filename,argstring):
def parse(inputstring): def parse(inputstring):
"parse(inputstring): returns a parsed output string" "parse(inputstring): returns a parsed output string"
print "postprocessing..." print("postprocessing...")
output = "" output = ""
@ -95,7 +95,7 @@ def parse(inputstring):
output += "N" + str(linenr + 30) + " G17 G80 G40 G90\n" output += "N" + str(linenr + 30) + " G17 G80 G40 G90\n"
output += "N" + str(linenr + 40) + " M99\n" output += "N" + str(linenr + 40) + " M99\n"
print "done postprocessing." print("done postprocessing.")
return output return output
print __name__ + " gcode postprocessor loaded." print(__name__ + " gcode postprocessor loaded.")

View File

@ -22,6 +22,7 @@
#* * #* *
#*************************************************************************** #***************************************************************************
from __future__ import print_function
TOOLTIP='''Post processor for Maho M 600E mill TOOLTIP='''Post processor for Maho M 600E mill
Machines with Philips or Heidenhain control should be very easy to adapt. Machines with Philips or Heidenhain control should be very easy to adapt.
@ -285,7 +286,7 @@ def export(selection,filename,argstring):
modalParamsDict[mp] = None modalParamsDict[mp] = None
for obj in selection: for obj in selection:
if not hasattr(obj,"Path"): if not hasattr(obj,"Path"):
print "the object " + obj.Name + " is not a path. Please select only path and Compounds." print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
return return
myMachine = None myMachine = None
for pathobj in selection: for pathobj in selection:
@ -297,7 +298,7 @@ def export(selection,filename,argstring):
else: else:
UNITS = "G20" UNITS = "G20"
if myMachine is None: if myMachine is None:
print "No machine found in this selection" print("No machine found in this selection")
gcode ='' gcode =''
gcode+= mkHeader(selection) gcode+= mkHeader(selection)

View File

@ -20,7 +20,7 @@
# * USA * # * USA *
# * * # * *
# ***************************************************************************/ # ***************************************************************************/
from __future__ import print_function
TOOLTIP=''' TOOLTIP='''
This is a postprocessor file for the Path workbench. It is used to This is a postprocessor file for the Path workbench. It is used to
@ -118,10 +118,10 @@ def export(objectslist, filename, argstring):
global UNITS global UNITS
for obj in objectslist: for obj in objectslist:
if not hasattr(obj, "Path"): if not hasattr(obj, "Path"):
print "the object " + obj.Name + " is not a path. Please select only path and Compounds." print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
return return
print "postprocessing..." print("postprocessing...")
gcode = "" gcode = ""
# Find the machine. # Find the machine.
@ -137,7 +137,7 @@ def export(objectslist, filename, argstring):
else: else:
UNITS = "G20" UNITS = "G20"
if myMachine is None: if myMachine is None:
print "No machine found in this selection" print("No machine found in this selection")
# write header # write header
if OUTPUT_HEADER: if OUTPUT_HEADER:
@ -186,7 +186,7 @@ def export(objectslist, filename, argstring):
else: else:
final = gcode final = gcode
print "done postprocessing." print("done postprocessing.")
if not filename == '-': if not filename == '-':
gfile = pythonopen(filename, "wb") gfile = pythonopen(filename, "wb")
@ -279,4 +279,4 @@ def parse(pathobj):
return out return out
print __name__ + " gcode postprocessor loaded." print(__name__ + " gcode postprocessor loaded.")

View File

@ -1,3 +1,4 @@
from __future__ import print_function
import datetime import datetime
from PathScripts import PostUtils from PathScripts import PostUtils
@ -81,14 +82,14 @@ def export(objectslist, filename, argstring):
if not hasattr(obj, "Path"): if not hasattr(obj, "Path"):
s = "the object " + obj.Name s = "the object " + obj.Name
s += " is not a path. Please select only path and Compounds." s += " is not a path. Please select only path and Compounds."
print s print(s)
return return
CurrentState = { CurrentState = {
'X': 0, 'Y': 0, 'Z': 0, 'F': 0, 'S': 0, 'X': 0, 'Y': 0, 'Z': 0, 'F': 0, 'S': 0,
'JSXY': 0, 'JSZ': 0, 'MSXY': 0, 'MSZ': 0 'JSXY': 0, 'JSZ': 0, 'MSXY': 0, 'MSZ': 0
} }
print "postprocessing..." print("postprocessing...")
gcode = "" gcode = ""
# write header # write header
@ -136,7 +137,7 @@ def export(objectslist, filename, argstring):
else: else:
final = gcode final = gcode
print "done postprocessing." print("done postprocessing.")
# Write the output # Write the output
gfile = pythonopen(filename, "wb") gfile = pythonopen(filename, "wb")
@ -216,11 +217,11 @@ def move(command):
txt += "," + format(command.Parameters["Z"], '.4f') txt += "," + format(command.Parameters["Z"], '.4f')
txt += "\n" txt += "\n"
elif axis == "": elif axis == "":
print "warning: skipping duplicate move." print("warning: skipping duplicate move.")
else: else:
print CurrentState print(CurrentState)
print command print(command)
print "I don't know how to handle '{}' for a move.".format(axis) print("I don't know how to handle '{}' for a move.".format(axis))
return txt return txt
@ -255,7 +256,7 @@ def tool_change(command):
def comment(command): def comment(command):
print "a comment" print("a comment")
return return
@ -314,8 +315,8 @@ def parse(pathobj):
if c.Parameters: if c.Parameters:
CurrentState.update(c.Parameters) CurrentState.update(c.Parameters)
else: else:
print "I don't know what the hell the command: ", print("I don't know what the hell the command: ",end='')
print command + " means. Maybe I should support it." print(command + " means. Maybe I should support it.")
return output return output
@ -323,6 +324,6 @@ def linenumber():
return "" return ""
print __name__ + " gcode postprocessor loaded." print(__name__ + " gcode postprocessor loaded.")
# eof # eof

View File

@ -46,6 +46,7 @@ TODO
Many other OpenSBP commands not handled Many other OpenSBP commands not handled
''' '''
from __future__ import print_function
import FreeCAD import FreeCAD
import os, Path import os, Path
@ -81,7 +82,7 @@ def insert(filename,docname):
def parse(inputstring): def parse(inputstring):
"parse(inputstring): returns a list of parsed output string" "parse(inputstring): returns a list of parsed output string"
print "preprocessing..." print("preprocessing...")
# split the input by line # split the input by line
lines = inputstring.split("\n") lines = inputstring.split("\n")
return_output = [] return_output = []
@ -182,7 +183,7 @@ def parse(inputstring):
if words[0] in ["CG"]: #Gcode circle/arc if words[0] in ["CG"]: #Gcode circle/arc
if words[1] != "": # diameter mode if words[1] != "": # diameter mode
print "diameter mode not supported" print("diameter mode not supported")
continue continue
else: else:
@ -201,9 +202,9 @@ def parse(inputstring):
#Make sure all appended paths have at least one move command. #Make sure all appended paths have at least one move command.
if any (x in output for x in movecommand): if any (x in output for x in movecommand):
return_output.append(output) return_output.append(output)
print "done preprocessing." print("done preprocessing.")
return return_output return return_output
print __name__ + " gcode preprocessor loaded." print(__name__ + " gcode preprocessor loaded.")