hpgl_output.py revision 405210bcba3f03624d5cbfaa76087005566d28fc
# coding=utf-8
'''
Copyright (C) 2008 Aaron Spike, aaron@ekips.org
Overcut, Tool Offset, Rotation, Serial Com., Many Bugfixes and Improvements: Sebastian Wüst, sebi@timewaster.de, http://www.timewasters-place.com/
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
help="Minimum flatness of the subdivided curves")
help="Mirror Y-Axis")
help="X offset (mm)")
help="Y offset (mm)")
help="Resolution (dpi)")
help="Pen number")
help="Plot invisible layers")
help="Use Overcut")
help="Overcut (mm)")
help="Correct tool offset")
help="Tool offset (mm)")
help="Return Factor")
help="Orientation")
help="Send to Plotter also")
help="Serial Port")
help="Baud Rate")
# initiate vars
mirror = 1.0
mirror = -1.0
# dryRun to find edges
# life run
self.groupmat = [[[scale, 0.0, -self.xDivergence + x0], [0.0, mirror*scale, -self.yDivergence + y0]]]
try:
import serial
except ImportError, e:
inkex.errormsg('pySerial is not installed.\n\n1. Download pySerial here: http://pypi.python.org/pypi/pyserial\n2. Extract the "serial" folder from the zip to the following folder: "C:\Program Files (x86)\inkscape\python\Lib"\n3. Restart Inkscape.')
self.S = serial.Serial(port=self.options.port, baudrate=self.options.baudRate, timeout=0.01, writeTimeout=None)
# process groups
if style:
return
if trans:
self.groupmat.append(simpletransform.composeTransform(self.groupmat[-1], simpletransform.parseTransform(trans)))
if trans:
# process oath
if d:
# transform path
p = cubicsuperpath.parsePath(d)
if trans:
mat = simpletransform.composeTransform(mat, simpletransform.parseTransform('rotate(' + self.options.rotation + ')'))
# break path into HPGL commands
xPosOld = -1
yPosOld = -1
for sp in p:
cmd = 'PU'
cmd = 'PD'
# perform overcut
break
# calc absoulute or relative length of two points
# calculate offset correction (or dont))
else:
self.changeLengthX(self.vData[1][1], self.vData[1][2], self.vData[2][1], self.vData[2][2], self.options.toolOffset),
self.changeLengthY(self.vData[1][1], self.vData[1][2], self.vData[2][1], self.vData[2][2], self.options.toolOffset))
xTemp = self.vData[1][1] - self.changeLengthX(self.vData[0][1], self.vData[0][2], self.vData[1][1], self.vData[1][2], self.options.toolOffset)
yTemp = self.vData[1][2] - self.changeLengthY(self.vData[0][1], self.vData[0][2], self.vData[1][1], self.vData[1][2], self.options.toolOffset)
else:
self.changeLengthX(self.vData[3][1], self.vData[3][2], self.vData[2][1], self.vData[2][2], -(self.options.toolOffset * self.options.toolOffsetReturn)),
self.changeLengthY(self.vData[3][1], self.vData[3][2], self.vData[2][1], self.vData[2][2], -(self.options.toolOffset * self.options.toolOffsetReturn)))
else:
else:
if x < 0: x = 0 # only positive values are allowed
if y < 0: y = 0
# change length between two points - x axis
# change length between two points - y axis
# print to file
if __name__ == '__main__':
# Raise recursion limit to avoid exceptions on big documents
# start calculations
e = MyEffect()
e.affect()
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99