1
1
2
- #!/usr/bin/env python
2
+ #!/usr/bin/env python3
3
3
'''
4
4
Copyright (C) 2017 Jarrett Rainier jrainier@gmail.com
5
5
23
23
24
24
'''
25
25
import inkex , cmath
26
- from inkex .paths import Path , ZoneClose , Move , Line , line
26
+ from inkex .paths import Path , ZoneClose , Move , Line , line , Curve
27
27
from lxml import etree
28
28
29
29
debugEn = False
@@ -62,18 +62,24 @@ def line(self, vector):
62
62
def get_line (self , n ):
63
63
'''Return the end points of the nth line in the path as complex numbers, as well as whether that line closes the path.'''
64
64
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 )
66
69
# If the next point in the path closes the path, go back to the start.
67
70
end = None
68
71
closePath = False
69
72
if isinstance (self [n + 1 ], ZoneClose ):
70
73
end = complex (self [0 ].x , self [0 ].y )
71
74
closePath = True
72
75
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 )
74
80
return (start , end , closePath )
75
81
76
- class QuickJoint (inkex .Effect ):
82
+ class QuickJoint (inkex .EffectExtension ):
77
83
def add_arguments (self , pars ):
78
84
pars .add_argument ('-s' , '--side' , type = int , default = 0 , help = 'Object face to tabify' )
79
85
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):
141
147
142
148
def draw_tabs (self , path , line ):
143
149
cursor , segCount , segment , closePath = self .get_segments (path , line , self .numtabs )
144
-
150
+
145
151
# Calculate kerf-compensated vectors for the parallel portion of tab and space
146
152
tabLine = self .draw_parallel (segment , segment , self .kerf )
147
153
spaceLine = self .draw_parallel (segment , segment , - self .kerf )
@@ -156,7 +162,7 @@ def draw_tabs(self, path, line):
156
162
drawTab = self .featureStart
157
163
newLines = QuickJointPath ()
158
164
159
- # First line is a move or line to our start point
165
+ # First line is a move or line to our start point
160
166
if isinstance (path [line ], Move ):
161
167
newLines .Move (cursor )
162
168
else :
@@ -266,16 +272,13 @@ def effect(self):
266
272
debugMsg (newPath )
267
273
debugMsg ('4' )
268
274
debugMsg ( p [lineNum + 1 :])
269
- finalPath = p [:lineNum ] + newPath + p [lineNum + 1 :]
270
-
275
+ finalPath = p [:lineNum + 1 ] + newPath + p [lineNum + 2 :]
276
+
271
277
debugMsg (finalPath )
272
278
273
279
node .set ('d' ,str (Path (finalPath )))
274
280
elif self .activetab == 'slotpage' :
275
281
newPath = self .draw_slots (p )
276
-
277
-
278
-
279
-
282
+
280
283
if __name__ == '__main__' :
281
284
QuickJoint ().run ()
0 commit comments