Skip to content

Commit

Permalink
Merge pull request #2 from fablabnbg/master
Browse files Browse the repository at this point in the history
try merge from fablabnbg
  • Loading branch information
jnweiger authored Jul 25, 2019
2 parents 8688392 + 731150b commit e01bcca
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 24 deletions.
232 changes: 232 additions & 0 deletions examples/registration-marks/registration-marks-cameo-silhouette-a4.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions sendto_silhouette.inx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
<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="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>
Expand Down Expand Up @@ -126,9 +128,9 @@ Always use the least amount of blade possible.
<param name="bladediameter_help" type="description">Correct value for the silhouette blade is 0.9mm</param>
</page>
<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 [juewei@fabmail.org] and contributors</param>
<param name="about_who" type="description">inkscape-silhouette extension from https://github.com/jnweiger/inkscape-silhouette by Jürgen Weigert [juergen@fabmail.org] 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
41 changes: 23 additions & 18 deletions sendto_silhouette.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@
# https://github.com/fablabnbg/inkscape-silhouette/pull/33
# Added new cutting strategy "Minimized Traveling"
# Added parameter for blade diameter
# 2019-07-25, jw, v1.20 -- merge from github.com/olegdeezus/inkscape-silhouette
# 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
__author__ = 'Juergen Weigert <juewei@fabmail.org> and contributors'
__version__ = '1.21' # Keep in sync with sendto_silhouette.inx ca line 79
__author__ = 'Juergen Weigert <juergen@fabmail.org> and contributors'

import sys, os, shutil, time, logging, tempfile
import sys, os, shutil, time, logging, tempfile, math, re


# we sys.path.append() the directory where this
Expand Down Expand Up @@ -137,9 +139,9 @@
def px2mm(px):
'''
Convert inkscape pixels to mm.
The default inkscape unit, called 'px' is 90dpi
The default inkscape unit, called 'px' is 96dpi
'''
return px*25.4/90
return px*25.4/96

# Lifted with impunity from eggbot.py
# Added all known inkscape units. https://github.com/fablabnbg/inkscape-silhouette/issues/19
Expand Down Expand Up @@ -932,11 +934,15 @@ def getLength( self, name, default ):
elif ( u == '' ) or ( u == 'px' ):
return v
elif u == 'mm':
return v*90./25.4 # inverse of px2mm
return v*96./25.4 # inverse of px2mm
elif u == 'in':
return v*90.
return v*96.
elif u == 'cm':
return v*90./2.54 # inverse of 10*px2mm
return v*96./2.54 # inverse of 10*px2mm
elif u == 'pt':
return v*96./72.
elif u == 'pc':
return v*96./16.
elif u == '%':
return float( default ) * v / 100.0
else:
Expand Down Expand Up @@ -1034,8 +1040,13 @@ def write_progress(done, total, msg):
self.pen=False
self.autoblade=True

# scale all points to unit mm
for path in self.paths:
for i,pt in enumerate(path):
path[i] = (px2mm(pt[0]), px2mm(pt[1]))

if self.options.strategy == 'matfree':
mf = MatFree('default', scale=px2mm(1.0), pen=self.pen)
mf = MatFree('default', scale=1.0, pen=self.pen)
mf.verbose = 0 # inkscape crashes whenever something appears in stdout.
self.paths = mf.apply(self.paths)
elif self.options.strategy == 'mintravel':
Expand All @@ -1047,14 +1058,8 @@ def write_progress(done, total, msg):
# print >>self.tty, self.paths
cut = []
pointcount = 0
for px_path in self.paths:
mm_path = []
for pt in px_path:
if self.options.strategy == 'matfree':
mm_path.append((pt[0], pt[1])) # MatFree.load() did the scaling already.
else:
mm_path.append((px2mm(pt[0]), px2mm(pt[1])))
pointcount += 1
for mm_path in self.paths:
pointcount += len(mm_path)

multipath = []
multipath.extend(mm_path)
Expand Down
9 changes: 5 additions & 4 deletions silhouette/Graphtec.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@

DEVICE = [
{ 'vendor_id': VENDOR_ID_GRAPHTEC, 'product_id': PRODUCT_ID_SILHOUETTE_PORTRAIT, 'name': 'Silhouette Portrait',
'width_mm': 203, 'length_mm': 3000, 'regmark': True },
'width_mm': 206, 'length_mm': 3000, 'regmark': True },
{ 'vendor_id': VENDOR_ID_GRAPHTEC, 'product_id': PRODUCT_ID_SILHOUETTE_PORTRAIT2, 'name': 'Silhouette Portrait2',
'width_mm': 203, 'length_mm': 3000, 'regmark': True },
{ 'vendor_id': VENDOR_ID_GRAPHTEC, 'product_id': PRODUCT_ID_SILHOUETTE_CAMEO, 'name': 'Silhouette Cameo',
Expand Down Expand Up @@ -490,7 +490,7 @@ def initialize(s):
#try:
# resp = s.read(timeout=1000)
# if len(resp) > 1:
# print("U: '%s'" % (resp[:-1]), file=s.log) # response '20320,4120' max. print range?
# print("U: '%s'" % (resp[:-1]), file=s.log) # response '20320,4120' max. usable print range?
#except:
# pass

Expand Down Expand Up @@ -721,7 +721,7 @@ def find_bbox(s, cut):
return bb

def flip_cut(s, cut):
"""this returns a flipped copy of the cut about the x-axis,
"""this returns a flipped copy of the cut about the y-axis,
keeping min and max values as they are."""
bb = s.find_bbox(cut)
new_cut = []
Expand Down Expand Up @@ -971,7 +971,8 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None,
#FEx,0 , x = 0 cutting of distinct paths in one go, x = 1 head is lifted at sharp angles
#\xmin, ymin Zxmax,ymax, designate cutting area

# needed at least for the trackenhancing feature, defines the usable length,
# needed only for the trackenhancing feature, defines the usable length, rollers three times forward and back.
# needs a pressure of 19 or more, else nothing will happen
#p = "FU%d\x03" % (height)
#p = "FU%d,%d\x03" % (height,width) # optional
#s.write(p)
Expand Down

0 comments on commit e01bcca

Please sign in to comment.