Skip to content

Commit

Permalink
Merge pull request #23 from Skrupellos/regmarks
Browse files Browse the repository at this point in the history
Regmarks -- Thanks!
I'll bump the version number and make a release with this!
  • Loading branch information
jnweiger committed May 15, 2016
2 parents 5eae5b7 + 64e7ecc commit e21adc3
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 7 deletions.
12 changes: 12 additions & 0 deletions sendto_silhouette.inx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,16 @@
<param name="reversetoggle" type="boolean" _gui-text="Cut in opposite direction(s)">false</param>
</page>

<page name='reg' _gui-text='Regmarks'>
<param name="regmark" type="boolean" _gui-text="The document has registration marks">false</param>
<param name="regmark_help" type="description">???</param>
<param name="regsearch" type="boolean" _gui-text="Search for the regitration marks">false</param>
<param name="regsearch_help" type="description">???</param>
<param name="regwidth" type="float" min="0.0" max="10000" _gui-text="X mark distance [mm]">180</param>
<param name="reglength" type="float" min="0.0" max="10000" _gui-text="Y mark distance [mm]">230</param>
<param name="regdistance_help" type="description">Distance of the registration mark edges</param>
</page>

<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>
Expand All @@ -62,6 +72,7 @@
<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>

<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]</param>
<!-- Keep in sync with sendto_silhouette.py line 103 __version__ = ... -->
Expand All @@ -75,6 +86,7 @@
<submenu _name="Export"/>
</effects-menu>
</effect>

<script>
<command reldir="extensions" interpreter="python">sendto_silhouette.py</command>
</script>
Expand Down
19 changes: 17 additions & 2 deletions sendto_silhouette.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ def __init__(self):
type = 'float', dest = 'x_off', default = 0.0, help="X-Offset [mm]")
self.OptionParser.add_option('-y', '--y-off', '--y_off', action = 'store',
type = 'float', dest = 'y_off', default = 0.0, help="Y-Offset [mm]")
self.OptionParser.add_option('-R', '--regmark',
action = 'store', dest = 'regmark', type = 'inkbool', default = False,
help="The document has registration marks.")
self.OptionParser.add_option('--regsearch',
action = 'store', dest = 'regsearch', type = 'inkbool', default = False,
help="Search for the regitration marks.")
self.OptionParser.add_option('-X', '--reg-x', '--regwidth', action = 'store',
type = 'float', dest = 'regwidth', default = 18.0, help="X mark distance [mm]")
self.OptionParser.add_option('-Y', '--reg-y', '--reglength', action = 'store',
type = 'float', dest = 'reglength', default = 230.0, help="Y mark distance [mm]")

def version(self):
return __version__
Expand Down Expand Up @@ -979,7 +989,10 @@ def write_progress(done, total, msg):
mediawidth=px2mm(self.docWidth),
mediaheight=px2mm(self.docHeight),
margintop=0, marginleft=0,
bboxonly=None) # only return the bbox, do not draw it.
bboxonly=None, # only return the bbox, do not draw it.
regmark=self.options.regmark,regsearch=self.options.regsearch,
regwidth=self.options.regwidth,reglength=self.options.reglength)

if len(bbox['bbox'].keys()):
print >>self.tty, "autocrop left=%.1fmm top=%.1fmm" % (
bbox['bbox']['llx']*bbox['unit'],
Expand All @@ -991,7 +1004,9 @@ def write_progress(done, total, msg):
mediawidth=px2mm(self.docWidth),
mediaheight=px2mm(self.docHeight),
offset=(self.options.x_off,self.options.y_off),
bboxonly=self.options.bboxonly)
bboxonly=self.options.bboxonly,
regmark=self.options.regmark,regsearch=self.options.regsearch,
regwidth=self.options.regwidth,reglength=self.options.reglength)
if len(bbox['bbox'].keys()) == 0:
print >>self.tty, "empty page?"
print >>sys.stderr, "empty page?"
Expand Down
39 changes: 34 additions & 5 deletions silhouette/Graphtec.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,10 @@ def plot_cmds(s, plist, bbox, x_off_mm, y_off_mm):
return plotcmds


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):
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, regmark=False, regsearch=False,
regwidth=180, reglength=230):
"""plot sends the pathlist to the device (real or dummy) and computes the
bounding box of the pathlist, which is returned.
Expand Down Expand Up @@ -675,11 +678,37 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, marginleft=None
offset = (offset, 0)

s.write("FU%d,%d\x03" % (height-top, width-left))
s.write("FM1\x03") # // ?
if s.regmark:
raise ValueError("regmark code not impl. see robocut/Plotter.cpp:446")
s.write("FN0\x03") # // ?
if regmark:
s.write("TB50,0\x03") #only with registration (it was TB50,1) ???
s.write("TB99\x03")
s.write("TB52,2\x03")
s.write("TB51,400\x03")
s.write("TB53,10\x03")
s.write("TB55,1\x03")

if regsearch:
cmd="123"
else:
cmd="23"
## registration mark test /1-2: 180.0mm / 1-3: 230.0mm (origin 15mmx20mm)
s.write("TB%s,%i,%i,118,18\x03" % (cmd, regwidth * 20.0, reglength * 20.0))

s.write("FQ5\x03") ## only with registration ???
resp = s.read(timeout=40000) ## Allow 20s for reply...
if resp != " 0\x03":
raise ValueError("Couldn't find registration marks. %s" % str(resp))

## 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)
resp = s.read(timeout=40000) ## Allow 20s for reply...
if resp != " 0\x03":
raise ValueError("Couldn't find registration marks.")

#resp = s.read(timeout=40000) ## Allow 20s for reply...
#if resp != " 1\x03":
#raise ValueError("Couldn't find registration marks.")
else:
s.write("TB50,1\x03") #; // ???
s.write("TB50,1\x03") # ???

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

0 comments on commit e21adc3

Please sign in to comment.