Skip to content

Commit 36ad103

Browse files
authored
Merge pull request #17 from vmario89/patch-1
Update quickjoint.py
2 parents b85e8fa + bb2b363 commit 36ad103

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

quickjoint.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
#!/usr/bin/env python
2+
#!/usr/bin/env python3
33
'''
44
Copyright (C) 2017 Jarrett Rainier jrainier@gmail.com
55
@@ -23,7 +23,7 @@
2323
2424
'''
2525
import inkex, cmath
26-
from inkex.paths import Path, ZoneClose, Move, Line, line
26+
from inkex.paths import Path, ZoneClose, Move, Line, line, Curve
2727
from lxml import etree
2828

2929
debugEn = False
@@ -62,18 +62,24 @@ def line(self, vector):
6262
def get_line(self, n):
6363
'''Return the end points of the nth line in the path as complex numbers, as well as whether that line closes the path.'''
6464

65-
start = complex(self[n].x, self[n].y)
65+
if isinstance(self[n], (Move, Line, ZoneClose)):
66+
start = complex(self[n].x, self[n].y)
67+
elif isinstance(self[n], Curve):
68+
start = complex(self[n].x4, self[n].y4)
6669
# If the next point in the path closes the path, go back to the start.
6770
end = None
6871
closePath = False
6972
if isinstance(self[n+1], ZoneClose):
7073
end = complex(self[0].x, self[0].y)
7174
closePath = True
7275
else:
73-
end = complex(self[n+1].x, self[n+1].y)
76+
if isinstance(self[n+1], (Move, Line, ZoneClose)):
77+
end = complex(self[n+1].x, self[n+1].y)
78+
elif isinstance(self[n+1], Curve):
79+
end = complex(self[n+1].x4, self[n+1].y4)
7480
return (start, end, closePath)
7581

76-
class QuickJoint(inkex.Effect):
82+
class QuickJoint(inkex.EffectExtension):
7783
def add_arguments(self, pars):
7884
pars.add_argument('-s', '--side', type=int, default=0, help='Object face to tabify')
7985
pars.add_argument('-n', '--numtabs', type=int, default=1, help='Number of tabs to add')
@@ -141,7 +147,7 @@ def draw_box(self, start, lengthVector, height, kerf):
141147

142148
def draw_tabs(self, path, line):
143149
cursor, segCount, segment, closePath = self.get_segments(path, line, self.numtabs)
144-
150+
145151
# Calculate kerf-compensated vectors for the parallel portion of tab and space
146152
tabLine = self.draw_parallel(segment, segment, self.kerf)
147153
spaceLine = self.draw_parallel(segment, segment, -self.kerf)
@@ -156,7 +162,7 @@ def draw_tabs(self, path, line):
156162
drawTab = self.featureStart
157163
newLines = QuickJointPath()
158164

159-
# First line is a move or line to our start point
165+
# First line is a move or line to our start point
160166
if isinstance(path[line], Move):
161167
newLines.Move(cursor)
162168
else:
@@ -266,16 +272,13 @@ def effect(self):
266272
debugMsg(newPath)
267273
debugMsg('4')
268274
debugMsg( p[lineNum + 1:])
269-
finalPath = p[:lineNum] + newPath + p[lineNum + 1:]
270-
275+
finalPath = p[:lineNum + 1] + newPath + p[lineNum + 2:]
276+
271277
debugMsg(finalPath)
272278

273279
node.set('d',str(Path(finalPath)))
274280
elif self.activetab == 'slotpage':
275281
newPath = self.draw_slots(p)
276-
277-
278-
279-
282+
280283
if __name__ == '__main__':
281284
QuickJoint().run()

0 commit comments

Comments
 (0)