-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from vmario89/patch-1
Update quickjoint.py
- Loading branch information
Showing
1 changed file
with
16 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
|
||
#!/usr/bin/env python | ||
#!/usr/bin/env python3 | ||
''' | ||
Copyright (C) 2017 Jarrett Rainier [email protected] | ||
|
@@ -23,7 +23,7 @@ | |
''' | ||
import inkex, cmath | ||
from inkex.paths import Path, ZoneClose, Move, Line, line | ||
from inkex.paths import Path, ZoneClose, Move, Line, line, Curve | ||
from lxml import etree | ||
|
||
debugEn = False | ||
|
@@ -62,18 +62,24 @@ def line(self, vector): | |
def get_line(self, n): | ||
'''Return the end points of the nth line in the path as complex numbers, as well as whether that line closes the path.''' | ||
|
||
start = complex(self[n].x, self[n].y) | ||
if isinstance(self[n], (Move, Line, ZoneClose)): | ||
start = complex(self[n].x, self[n].y) | ||
elif isinstance(self[n], Curve): | ||
start = complex(self[n].x4, self[n].y4) | ||
# If the next point in the path closes the path, go back to the start. | ||
end = None | ||
closePath = False | ||
if isinstance(self[n+1], ZoneClose): | ||
end = complex(self[0].x, self[0].y) | ||
closePath = True | ||
else: | ||
end = complex(self[n+1].x, self[n+1].y) | ||
if isinstance(self[n+1], (Move, Line, ZoneClose)): | ||
end = complex(self[n+1].x, self[n+1].y) | ||
elif isinstance(self[n+1], Curve): | ||
end = complex(self[n+1].x4, self[n+1].y4) | ||
return (start, end, closePath) | ||
|
||
class QuickJoint(inkex.Effect): | ||
class QuickJoint(inkex.EffectExtension): | ||
def add_arguments(self, pars): | ||
pars.add_argument('-s', '--side', type=int, default=0, help='Object face to tabify') | ||
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): | |
|
||
def draw_tabs(self, path, line): | ||
cursor, segCount, segment, closePath = self.get_segments(path, line, self.numtabs) | ||
|
||
# Calculate kerf-compensated vectors for the parallel portion of tab and space | ||
tabLine = self.draw_parallel(segment, segment, self.kerf) | ||
spaceLine = self.draw_parallel(segment, segment, -self.kerf) | ||
|
@@ -156,7 +162,7 @@ def draw_tabs(self, path, line): | |
drawTab = self.featureStart | ||
newLines = QuickJointPath() | ||
|
||
# First line is a move or line to our start point | ||
# First line is a move or line to our start point | ||
if isinstance(path[line], Move): | ||
newLines.Move(cursor) | ||
else: | ||
|
@@ -266,16 +272,13 @@ def effect(self): | |
debugMsg(newPath) | ||
debugMsg('4') | ||
debugMsg( p[lineNum + 1:]) | ||
finalPath = p[:lineNum] + newPath + p[lineNum + 1:] | ||
finalPath = p[:lineNum + 1] + newPath + p[lineNum + 2:] | ||
|
||
debugMsg(finalPath) | ||
|
||
node.set('d',str(Path(finalPath))) | ||
elif self.activetab == 'slotpage': | ||
newPath = self.draw_slots(p) | ||
|
||
|
||
|
||
|
||
|
||
if __name__ == '__main__': | ||
QuickJoint().run() |