Skip to content

Commit e21adc3

Browse files
committed
Merge pull request #23 from Skrupellos/regmarks
Regmarks -- Thanks! I'll bump the version number and make a release with this!
2 parents 5eae5b7 + 64e7ecc commit e21adc3

File tree

3 files changed

+63
-7
lines changed

3 files changed

+63
-7
lines changed

sendto_silhouette.inx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,16 @@
5454
<param name="reversetoggle" type="boolean" _gui-text="Cut in opposite direction(s)">false</param>
5555
</page>
5656

57+
<page name='reg' _gui-text='Regmarks'>
58+
<param name="regmark" type="boolean" _gui-text="The document has registration marks">false</param>
59+
<param name="regmark_help" type="description">???</param>
60+
<param name="regsearch" type="boolean" _gui-text="Search for the regitration marks">false</param>
61+
<param name="regsearch_help" type="description">???</param>
62+
<param name="regwidth" type="float" min="0.0" max="10000" _gui-text="X mark distance [mm]">180</param>
63+
<param name="reglength" type="float" min="0.0" max="10000" _gui-text="Y mark distance [mm]">230</param>
64+
<param name="regdistance_help" type="description">Distance of the registration mark edges</param>
65+
</page>
66+
5767
<page name='advanced' _gui-text='Advanced'>
5868
<param name="wait_done" type="boolean" _gui-text="Wait til done, after all data is sent">false</param>
5969
<param name="wait_done_help" type="description">Keep dialog open until device becomes idle again.</param>
@@ -62,6 +72,7 @@
6272
<param name="dummy" type="boolean" _gui-text="Dummy device: Send to /tmp/silhouette.dump">false</param>
6373
<param name="dummy_help" type="description">Used for debugging and developent only!</param>
6474
</page>
75+
6576
<page name='about' _gui-text='About'>
6677
<param name="about_who" type="description">inkscape-silhouette extension from https://github.com/jnweiger/inkscape-silhouette by Jürgen Weigert [juewei@fabmail.org]</param>
6778
<!-- Keep in sync with sendto_silhouette.py line 103 __version__ = ... -->
@@ -75,6 +86,7 @@
7586
<submenu _name="Export"/>
7687
</effects-menu>
7788
</effect>
89+
7890
<script>
7991
<command reldir="extensions" interpreter="python">sendto_silhouette.py</command>
8092
</script>

sendto_silhouette.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,16 @@ def __init__(self):
272272
type = 'float', dest = 'x_off', default = 0.0, help="X-Offset [mm]")
273273
self.OptionParser.add_option('-y', '--y-off', '--y_off', action = 'store',
274274
type = 'float', dest = 'y_off', default = 0.0, help="Y-Offset [mm]")
275+
self.OptionParser.add_option('-R', '--regmark',
276+
action = 'store', dest = 'regmark', type = 'inkbool', default = False,
277+
help="The document has registration marks.")
278+
self.OptionParser.add_option('--regsearch',
279+
action = 'store', dest = 'regsearch', type = 'inkbool', default = False,
280+
help="Search for the regitration marks.")
281+
self.OptionParser.add_option('-X', '--reg-x', '--regwidth', action = 'store',
282+
type = 'float', dest = 'regwidth', default = 18.0, help="X mark distance [mm]")
283+
self.OptionParser.add_option('-Y', '--reg-y', '--reglength', action = 'store',
284+
type = 'float', dest = 'reglength', default = 230.0, help="Y mark distance [mm]")
275285

276286
def version(self):
277287
return __version__
@@ -979,7 +989,10 @@ def write_progress(done, total, msg):
979989
mediawidth=px2mm(self.docWidth),
980990
mediaheight=px2mm(self.docHeight),
981991
margintop=0, marginleft=0,
982-
bboxonly=None) # only return the bbox, do not draw it.
992+
bboxonly=None, # only return the bbox, do not draw it.
993+
regmark=self.options.regmark,regsearch=self.options.regsearch,
994+
regwidth=self.options.regwidth,reglength=self.options.reglength)
995+
983996
if len(bbox['bbox'].keys()):
984997
print >>self.tty, "autocrop left=%.1fmm top=%.1fmm" % (
985998
bbox['bbox']['llx']*bbox['unit'],
@@ -991,7 +1004,9 @@ def write_progress(done, total, msg):
9911004
mediawidth=px2mm(self.docWidth),
9921005
mediaheight=px2mm(self.docHeight),
9931006
offset=(self.options.x_off,self.options.y_off),
994-
bboxonly=self.options.bboxonly)
1007+
bboxonly=self.options.bboxonly,
1008+
regmark=self.options.regmark,regsearch=self.options.regsearch,
1009+
regwidth=self.options.regwidth,reglength=self.options.reglength)
9951010
if len(bbox['bbox'].keys()) == 0:
9961011
print >>self.tty, "empty page?"
9971012
print >>sys.stderr, "empty page?"

silhouette/Graphtec.py

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,10 @@ def plot_cmds(s, plist, bbox, x_off_mm, y_off_mm):
604604
return plotcmds
605605

606606

607-
def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, marginleft=None, pathlist=None, offset=None, bboxonly=False, end_paper_offset=0, no_trailer=False):
607+
def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None,
608+
marginleft=None, pathlist=None, offset=None, bboxonly=False,
609+
end_paper_offset=0, no_trailer=False, regmark=False, regsearch=False,
610+
regwidth=180, reglength=230):
608611
"""plot sends the pathlist to the device (real or dummy) and computes the
609612
bounding box of the pathlist, which is returned.
610613
@@ -675,11 +678,37 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, marginleft=None
675678
offset = (offset, 0)
676679

677680
s.write("FU%d,%d\x03" % (height-top, width-left))
678-
s.write("FM1\x03") # // ?
679-
if s.regmark:
680-
raise ValueError("regmark code not impl. see robocut/Plotter.cpp:446")
681+
s.write("FN0\x03") # // ?
682+
if regmark:
683+
s.write("TB50,0\x03") #only with registration (it was TB50,1) ???
684+
s.write("TB99\x03")
685+
s.write("TB52,2\x03")
686+
s.write("TB51,400\x03")
687+
s.write("TB53,10\x03")
688+
s.write("TB55,1\x03")
689+
690+
if regsearch:
691+
cmd="123"
692+
else:
693+
cmd="23"
694+
## registration mark test /1-2: 180.0mm / 1-3: 230.0mm (origin 15mmx20mm)
695+
s.write("TB%s,%i,%i,118,18\x03" % (cmd, regwidth * 20.0, reglength * 20.0))
696+
697+
s.write("FQ5\x03") ## only with registration ???
698+
resp = s.read(timeout=40000) ## Allow 20s for reply...
699+
if resp != " 0\x03":
700+
raise ValueError("Couldn't find registration marks. %s" % str(resp))
701+
702+
## Looks like if the reg marks work it gets 3 messages back (if it fails it times out because it only gets the first message)
703+
resp = s.read(timeout=40000) ## Allow 20s for reply...
704+
if resp != " 0\x03":
705+
raise ValueError("Couldn't find registration marks.")
706+
707+
#resp = s.read(timeout=40000) ## Allow 20s for reply...
708+
#if resp != " 1\x03":
709+
#raise ValueError("Couldn't find registration marks.")
681710
else:
682-
s.write("TB50,1\x03") #; // ???
711+
s.write("TB50,1\x03") # ???
683712

684713
# // I think this is the feed command. Sometimes it is 5588 - maybe a maximum?
685714
s.write("FO%d\x03" % (height-top))

0 commit comments

Comments
 (0)