Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jnweiger authored Jul 25, 2019
2 parents 8b38e2e + 8688392 commit 731150b
Show file tree
Hide file tree
Showing 17 changed files with 1,285 additions and 95 deletions.
Binary file not shown.
Binary file added logs/silhouette_cameo3_autoblade_depth5.pcapng.gz
Binary file not shown.
Binary file added logs/silhouette_cameo3_default_settings.pcapng.gz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added logs/silhouette_cameo3_no_cutting_mat.pcapng.gz
Binary file not shown.
Binary file added logs/silhouette_cameo3_pen.pcapng.gz
Binary file not shown.
Binary file added logs/silhouette_cameo3_ratchet_blade.pcapng.gz
Binary file not shown.
Binary file added logs/silhouette_cameo3_tool_2.pcapng.gz
Binary file not shown.
Binary file added logs/silhouette_cameo3_track_enhancing.pcapng.gz
Binary file not shown.
29 changes: 22 additions & 7 deletions sendto_silhouette.inx
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,34 @@
<dependency type="executable" location="extensions">sendto_silhouette.py</dependency>
<param name="active-tab" type="notebook">
<page name='silhouette' _gui-text='Silhouette'>
<param name="x_off" type="float" min="-999.0" max="999.0" _gui-text="X-Offset [mm]">0.0</param>
<param name="y_off" type="float" min="-999.0" max="999.0" _gui-text="Y-Offset [mm]">0.0</param>
<param name="x_off" type="float" min="-999.0" max="999.0" precision="2" _gui-text="X-Offset [mm]">0.0</param>
<param name="y_off" type="float" min="-999.0" max="999.0" precision="2" _gui-text="Y-Offset [mm]">0.0</param>
<param name="cuttingmat" type="enum" _gui-text="Cutting Mat:">
<item value="cameo_12x12">Cameo 12x12</item>
<item value="cameo_12x24">Cameo 12x24</item>
<item value="no_mat">None</item>
</param>
<param name="toolholder" type="enum" _gui-text="Tool Holder:">
<item value="1">Red (left tool)</item>
<item value="2">Blue (right tool)</item>
</param>
<param name="tool" type="enum" _gui-text="Tool:">
<item value="default">Media default</item>
<item value="pen">Pen</item>
<item value="cut">Cut</item>
<item value="autoblade">AutoBlade</item>
</param>
<param name="pen_help" type="description">'pen' executes the strokes exactly as sent, 'cut' adds small serifs to help the knive find its orientation at corners.</param>
<!-- CAUTION: keep media list in sync with silhouette/Graphtec.py -->
<param name="media" type="enum" _gui-text="Media:">
<item value="300">[P>0 S>0] Custom: use non-zero Pressure and Speed below</item>
<item value="100">[P=27,S=10] SCard without Craft Paper Backing</item>
<item value="101">[P=27,S=10] Card with Craft Paper Backing</item>
<item value="102">[P=10,S=10] Vinyl Sticker</item>
<item value="102">[P=10,S= 5,D=1] Vinyl Sticker</item>
<item value="106">[P=14,S=10] Film Labels</item>
<item value="111">[P=27,S=10] Thick Media</item>
<item value="112">[P= 2,S=10] Thin Media</item>
<item value="113">[P=10,S=10] Pen</item>
<item value="113">[P=18,S=10] Pen</item>
<item value="120">[P=30,S=10] Bond Paper 13-28 lbs (105g)</item>
<item value="121">[P=30,S=10] Bristol Paper 57-67 lbs (145g)</item>
<item value="122">[P=30,S=10] Cardstock 40-60 lbs (90g)</item>
Expand All @@ -47,14 +57,14 @@
</param>
<param name="speed" type="int" min="0" max="10" _gui-text="Speed">0</param>
<param name="pressure" type="int" min="0" max="33" _gui-text="Pressure">0</param>
<param name="depth" type="int" min="-1" max="10" _gui-text="Blade Depth (for AutoBlade)">-1</param>
<param name="speed_help" type="description">Use speed=0, pressure=0, depth=-1 to take the media defaults. Pressure values of 19 or more could trigger the trackenhancing feature, which means a movement along the full media height before start. Beware.</param>
</page>
<page name='opt' _gui-text='Options'>
<param name="speed_help" type="description">Use speed=0, pressure=0 to take the media defaults. Pressure values of 19 or more could trigger the trackenhancing feature, which means a movement along the full media height before start. Beware.</param>
<param name="dashes" type="boolean" _gui-text="Convert to dashes">false</param> <param name="dashes_help" type="description">Convert paths with dashed strokes to separate subpaths for perforated cuts.</param>
<param name="autocrop" type="boolean" _gui-text="Trim margins">false</param> <param name="autocrop_help" type="description">Shift to the top lefthand corner, then do offsets.</param>
<param name="bbox_only" type="boolean" _gui-text="Draft Bounding Box Only">false</param>
<param name="bbox_help" type="description">To see the used area, tick the checkmark above and use pressure=1 (or better remove tool)</param>
<param name="overcut" type="float" min="0.0" max="5.0" _gui-text="Overcut on closed paths [mm]">0.5</param>
<param name="multipass" type="int" min="1" max="8" _gui-text="Repeat each stroke">1</param>
<param name="reversetoggle" type="boolean" _gui-text="Cut in opposite direction(s)">false</param>
<param name="endposition" type="enum" _gui-text="Position After Cutting:">
Expand All @@ -79,6 +89,10 @@
<page name='advanced' _gui-text='Advanced'>
<param name="wait_done" type="boolean" _gui-text="Wait til done, after all data is sent">false</param>
<param name="wait_done_help" type="description">Keep dialog open until device becomes idle again.</param>
<param name="sharpencorners" type="boolean" _gui-text="Sharpen Corners">false</param> <param name="sharpencorners_help" type="description">Lift head at sharp corners</param>
<param name="sharpencorners_start" type="float" min="0.1" max="0.9" _gui-text="Sharpen Corners - Start Ext. [mm]">0.1</param>
<param name="sharpencorners_end" type="float" min="0.1" max="0.9" _gui-text="Sharpen Corners - End Ext. [mm]">0.1</param>
<param name="overcut" type="float" min="0.0" max="5.0" _gui-text="Overcut on closed paths [mm]">0.5</param>
<param name="strategy" type="enum" _gui-text="Cutting Strategy:">
<item value="zorder">Z-Order</item>
<item value="matfree">Without mat</item>
Expand All @@ -89,6 +103,7 @@
<param name="mat_free_help" type="description">Without mat: Subdivide, sort, and choose cut directions, so that a cutting mat is not needed in most cases.</param>
<param name="mintravel_help" type="description">Minimal Traveling: Find the nearest startpoint to minimize travel movements</param>
<param name="mintravelfull_help" type="description">Minimal Traveling (fully optimized): Additionally search startpoints in closed paths</param>
<param name="sw_clipping" type="boolean" _gui-text="Enable Software Clipping">true</param>
<param name="dummy" type="boolean" _gui-text="Dummy device: Send to /tmp/silhouette.dump">false</param>
<param name="dummy_help" type="description">Used for debugging and developent only!</param>
</page>
Expand All @@ -115,7 +130,7 @@ Always use the least amount of blade possible.
<page name='about' _gui-text='About'>
<param name="about_who" type="description">inkscape-silhouette extension from https://github.com/jnweiger/inkscape-silhouette by Jürgen Weigert [[email protected]] and contributors</param>
<!-- Keep in sync with sendto_silhouette.py line 78 __version__ = ... -->
<param name="about_version" type="description">Version 1.20</param>
<param name="about_version" type="description">Version 1.21</param>
</page>
</param>

Expand Down
88 changes: 73 additions & 15 deletions sendto_silhouette.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,21 @@
# Added misc/silhouette_move.py misc/silhouette_cut.py, misc/endless_clock.py
# 2016-01-15 jw, v1.15 -- ubuntu loads the wrong usb library.
# 2016-05-15 jw, v1.16 -- merged regmarks code from https://github.com/fablabnbg/inkscape-silhouette/pull/23
# 2016-05-17 jw, v1.17 -- fix avoid dev.reset in Graphtec.py, fix helps with
# 2016-05-17 jw, v1.17 -- fix avoid dev.reset in Graphtec.py, fix helps with
# https://github.com/fablabnbg/inkscape-silhouette/issues/10
# 2016-05-21 jw, v1.18 -- warn about python-usb < 1.0 and give instructions.
# Limit pressure to 18. 19 or 20 make the machine
# Limit pressure to 18. 19 or 20 make the machine
# scroll forward backward for several minutes.
# Support document unit inches. https://github.com/fablabnbg/inkscape-silhouette/issues/19
# 2016-12-18, jw, v1.19 -- support for dashed lines added. Thanks to mehtank
# https://github.com/fablabnbg/inkscape-silhouette/pull/33
# Added new cutting strategy "Minimized Traveling"
# Added parameter for blade diameter
# 2018-06-01, jw, v1.20-- Make it compile again. Hmm.
# 2018-06-01, jw, v1.20 -- Make it compile again. Hmm.
# 2019-07-25, jw, v1.21 -- merge from github.com/olegdeezus/inkscape-silhouette
# merge from fablabnbg

__version__ = '1.20' # Keep in sync with sendto_silhouette.inx ca line 79
__version__ = '1.21' # Keep in sync with sendto_silhouette.inx ca line 79
__author__ = 'Juergen Weigert <[email protected]> and contributors'

import sys, os, shutil, time, logging, tempfile, math, re
Expand Down Expand Up @@ -276,13 +278,22 @@ def __init__(self):
self.OptionParser.add_option('-c', '--bladediameter',
action = 'store', dest = 'bladediameter', type = 'float', default = 0.9,
help="[0..2.3] diameter of the used blade [mm], default = 0.9")
self.OptionParser.add_option('-C', '--cuttingmat', action = 'store',
choices=('cameo_12x12', 'cameo_12x24', 'no_mat'), dest = 'cuttingmat', default = 'cameo_12x12',
help='Use cutting mat')
self.OptionParser.add_option('-D', '--depth',
action = 'store', dest = 'depth', type = 'int', default = -1,
help="[0..10], or -1 for media default")
self.OptionParser.add_option('--dummy',
action = 'store', dest = 'dummy', type = 'inkbool', default = False,
help="Dump raw data to "+self.dumpname+" instead of cutting.")
self.OptionParser.add_option('-g', '--strategy',
action = 'store', dest = 'strategy', default = 'mintravel',
choices=('mintravel','mintravelfull','matfree','zorder' ),
help="Cutting Strategy: mintravel, mintravelfull, matfree or zorder")
self.OptionParser.add_option('-l', '--sw_clipping',
action = 'store', dest = 'sw_clipping', type = 'inkbool', default = True,
help='Enable software clipping')
self.OptionParser.add_option('-m', '--media', '--media-id', '--media_id',
action = 'store', dest = 'media', default = '132',
choices=('100','101','102','106','111','112','113',
Expand All @@ -298,6 +309,15 @@ def __init__(self):
self.OptionParser.add_option('-p', '--pressure',
action = 'store', dest = 'pressure', type = 'int', default = 10,
help="[1..18], or 0 for media default")
self.OptionParser.add_option('-P', '--sharpencorners',
action = 'store', dest = 'sharpencorners', type = 'inkbool', default = False,
help='Lift head at sharp corners')
self.OptionParser.add_option('--sharpencorners_start',
action = 'store', dest = 'sharpencorners_start', type = 'float', default = 0.1,
help="Sharpen Corners - Start Ext. [mm]")
self.OptionParser.add_option('--sharpencorners_end',
action = 'store', dest = 'sharpencorners_end', type = 'float', default = 0.1,
help="Sharpen Corners - End Ext. [mm]")
self.OptionParser.add_option('-r', '--reversetoggle',
action = 'store', dest = 'reversetoggle', type = 'inkbool', default = False,
help="Cut each path the other direction. Affects every second pass when multipass.")
Expand All @@ -307,7 +327,9 @@ def __init__(self):
self.OptionParser.add_option( "-S", "--smoothness", action="store", type="float",
dest="smoothness", default=.2, help="Smoothness of curves" )
self.OptionParser.add_option('-t', '--tool', action = 'store',
choices=('cut', 'pen','default'), dest = 'tool', default = None, help="Optimize for pen or knive")
choices=('autoblade', 'cut', 'pen','default'), dest = 'tool', default = None, help="Optimize for pen or knive")
self.OptionParser.add_option('-T', '--toolholder', action = 'store',
choices=('1', '2'), dest = 'toolholder', default = None, help="[1..2]")
self.OptionParser.add_option('-V', '--version',
action = 'store_const', const=True, dest = 'version', default = False,
help='Just print version number ("'+__version__+'") and exit.')
Expand Down Expand Up @@ -475,11 +497,18 @@ def recursivelyTraverseSvg( self, aNodeList,

for node in aNodeList:
# Ignore invisible nodes
v = node.get( 'visibility', parent_visibility )
v = None
style = node.get('style')
if style is not None:
kvs = {k.strip():v.strip() for k,v in [x.split(':', 1) for x in style.split(';')]}
if 'display' in kvs and kvs['display'] == 'none':
v = 'hidden'
if v is None:
v = node.get( 'visibility', parent_visibility )
if v == 'inherit':
v = parent_visibility
if v == 'hidden' or v == 'collapse':
pass
continue

# calculate this object's transform
transform = composeParents(node, IDENTITY_TRANSFORM)
Expand Down Expand Up @@ -1001,9 +1030,15 @@ def write_progress(done, total, msg):
# Traverse the entire document
self.recursivelyTraverseSvg( self.document.getroot() )

if self.options.toolholder is not None:
self.options.toolholder = int(self.options.toolholder)
self.pen=None
self.autoblade=False
if self.options.tool == 'pen': self.pen=True
if self.options.tool == 'cut': self.pen=False
if self.options.tool == 'autoblade':
self.pen=False
self.autoblade=True

# scale all points to unit mm
for path in self.paths:
Expand Down Expand Up @@ -1044,6 +1079,20 @@ def write_progress(done, total, msg):
# on a closed path some overlapping doesn't harm, limited to a maximum of one additional round
overcut = self.options.overcut
if (overcut > 0) and self.is_closed_path(mm_path):
precut = overcut
pfrom = mm_path[-1]
for pprev in reversed(mm_path[:-1]):
dx = pprev[0] - pfrom[0]
dy = pprev[1] - pfrom[1]
dist = math.sqrt(dx*dx + dy*dy)
if (precut > dist): # Full segment needed
precut -= dist
multipath.insert(0, pprev)
pfrom = pprev
else: # only partial segement needed, create new endpoint
pprev = (pfrom[0]+dx*(precut/dist), pfrom[1]+dy*(precut/dist))
multipath.insert(0, pprev)
break
pfrom = mm_path[0]
for pnext in mm_path[1:]:
dx = pnext[0] - pfrom[0]
Expand Down Expand Up @@ -1082,7 +1131,16 @@ def write_progress(done, total, msg):

if self.options.pressure == 0: self.options.pressure = None
if self.options.speed == 0: self.options.speed = None
if self.options.depth == -1: self.options.depth = None
dev.setup(media=int(self.options.media,10), pen=self.pen,
toolholder=self.options.toolholder,
cuttingmat=self.options.cuttingmat,
sharpencorners=self.options.sharpencorners,
sharpencorners_start=self.options.sharpencorners_start,
sharpencorners_end=self.options.sharpencorners_end,
autoblade=self.autoblade,
depth=self.options.depth,
sw_clipping=self.options.sw_clipping,
bladediameter=self.options.bladediameter,
pressure=self.options.pressure, speed=self.options.speed)

Expand Down Expand Up @@ -1163,15 +1221,15 @@ def write_progress(done, total, msg):
e = SendtoSilhouette()

if len(sys.argv) < 2:
# write a tempfile that is autoremoved on exit
tmpfile=tempfile.NamedTemporaryFile(suffix='.svg', prefix='inkscape-silhouette')
sys.argv.append(tmpfile.name)
print sys.argv
print >>tmpfile, '<xml height="10"></xml>'
tmpfile.flush()
# write a tempfile that is autoremoved on exit
tmpfile=tempfile.NamedTemporaryFile(suffix='.svg', prefix='inkscape-silhouette')
sys.argv.append(tmpfile.name)
print sys.argv
print >>tmpfile, '<xml height="10"></xml>'
tmpfile.flush()
e.affect(sys.argv[1:])
# os.remove(tmpfile.name)
sys.exit(0)
# os.remove(tmpfile.name)
sys.exit(0)

start = time.time()
e.affect()
Expand Down
Loading

0 comments on commit 731150b

Please sign in to comment.