opensbp preprocessor handles float for spindle speed

This commit is contained in:
sliptonic 2016-07-01 15:16:02 -05:00 committed by Yorik van Havre
parent fd57f47e3d
commit ee5bb83a38

View File

@ -1,26 +1,25 @@
#*************************************************************************** # ***************************************************************************
#* (c) sliptonic (shopinthewoods<at>gmail.com) 2014 * # * (c) sliptonic (shopinthewoods<at>gmail.com) 2014 *
#* * # * *
#* This file is part of the FreeCAD CAx development system. * # * This file is part of the FreeCAD CAx development system. *
#* * # * *
#* This program is free software; you can redistribute it and/or modify * # * This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) * # * it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of * # * as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. * # * the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. * # * for detail see the LICENCE text file. *
#* * # * *
#* FreeCAD is distributed in the hope that it will be useful, * # * FreeCAD is distributed in the hope that it will be useful, *
#* but WITHOUT ANY WARRANTY; without even the implied warranty of * # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
#* GNU Lesser General Public License for more details. * # * GNU Lesser General Public License for more details. *
#* * # * *
#* You should have received a copy of the GNU Library General Public * # * You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software * # * License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA * # * USA *
#* * # * *
#***************************************************************************/ # ***************************************************************************/
''' '''
This is a preprocessor file for the Path workbench. Its aim is to This is a preprocessor file for the Path workbench. Its aim is to
@ -84,7 +83,6 @@ 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 = []
@ -95,6 +93,7 @@ def parse(inputstring):
movecommand = ['G1', 'G0', 'G02', 'G03'] movecommand = ['G1', 'G0', 'G02', 'G03']
for l in lines: for l in lines:
print l
# remove any leftover trailing and preceding spaces # remove any leftover trailing and preceding spaces
l = l.strip() l = l.strip()
if not l: if not l:
@ -142,7 +141,7 @@ def parse(inputstring):
speed = lastfeedspeed["XY"] speed = lastfeedspeed["XY"]
else: else:
speed = lastfeedspeed[words[0][1]] speed = lastfeedspeed[words[0][1]]
last[words[0][1]] = words[1] last[words[0][1]] = words[1]
output += s + words[0][1] + str(words[1]) + " F" + speed + "\n" output += s + words[0][1] + str(words[1]) + " F" + speed + "\n"
@ -171,11 +170,11 @@ def parse(inputstring):
continue continue
if words[0] in ["TR"]: #Setting spindle speed if words[0] in ["TR"]: #Setting spindle speed
if int(words[1]) < 0: if float(words[1]) < 0:
s = "M4 S" s = "M4 S"
else: else:
s = "M3 S" s = "M3 S"
s += str(abs(int(words[1]))) s += str(abs(float(words[1])))
output += s + '\n' output += s + '\n'
if words[0] in ["CG"]: #Gcode circle/arc if words[0] in ["CG"]: #Gcode circle/arc