hpgl_output.py revision fb3047e8f36ad1bfeffca7b1e233967ca9d3a66d
# 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="Center Zero Point")
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
# get viewBox parameter to correct scaling
if viewBox:
# dryRun to find edges
self.groupmat[0] = simpletransform.composeTransform(self.groupmat[0], simpletransform.parseTransform('rotate(' + self.options.rotation + ')'))
# life run
self.groupmat = [[[scale*viewBoxTransformX, 0.0, -self.xDivergence + x0], [0.0, mirror*scale*viewBoxTransformY, -self.yDivergence + y0]]]
self.groupmat[0] = simpletransform.composeTransform(self.groupmat[0], simpletransform.parseTransform('rotate(' + self.options.rotation + ')'))
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:
# 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
if temp3 < -1:
temp3 = -1
# calculate offset correction (or dont))
else:
if self.getAlpha(self.vData[1][1], self.vData[1][2], self.vData[2][1], self.vData[2][2], self.vData[3][1], self.vData[3][2]) > 2.748893:
return
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))
self.vData[2][1] - (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)),
self.vData[2][2] - (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