From b1ff5013bb0076c67f24ff7c06ea7a1831bae511 Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Wed, 15 Jun 2016 23:11:25 +0200 Subject: [PATCH 01/12] Added an example svg file for the registration marks. --- examples/registration-marks.svg | 119 ++++++++++++++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 examples/registration-marks.svg diff --git a/examples/registration-marks.svg b/examples/registration-marks.svg new file mode 100644 index 00000000..9373bc2c --- /dev/null +++ b/examples/registration-marks.svg @@ -0,0 +1,119 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + 230mm + 180mm + + + From 685ebe959b1dc8577666cf65173b986409770c4a Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Wed, 15 Jun 2016 23:53:38 +0200 Subject: [PATCH 02/12] Added another resource of commands. --- Commands.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Commands.md b/Commands.md index 99ab2a56..a961a6c9 100644 --- a/Commands.md +++ b/Commands.md @@ -13,6 +13,7 @@ Resources * https://github.com/vishnubob/silhouette/blob/master/src/gpgl.py * https://github.com/jnweiger/robocut/blob/master/Plotter.cpp#L344-L586 * https://github.com/fablabnbg/inkscape-silhouette/blob/master/silhouette/Graphtec.py#L305-L419 + * https://github.com/Skrupellos/silhouette/blob/master/decode Typical sequence ---------------- From f970b0169ce7f86d5fc41abebcb1c7ec8fe088b4 Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Sat, 18 Jun 2016 14:36:23 +0200 Subject: [PATCH 03/12] Fill info field for registration marks. --- sendto_silhouette.inx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sendto_silhouette.inx b/sendto_silhouette.inx index 7a28525e..4973afb5 100644 --- a/sendto_silhouette.inx +++ b/sendto_silhouette.inx @@ -59,9 +59,9 @@ Pressure values of 19 or more make the machine misbehave. Beware. false - ??? - false - ??? + The document contains printed registration marks + false + Search for the registration marks automatically. Seems on some devices there is another mode, where you can set the references manually. 180 230 Distance of the registration mark edges From 63dbf18bd505bf66aa3c17563c76d9e30e6a94d5 Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Mon, 20 Jun 2016 18:23:22 +0200 Subject: [PATCH 04/12] Correct the check of the return state of the regmark code Add some comments --- silhouette/Graphtec.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/silhouette/Graphtec.py b/silhouette/Graphtec.py index 88f12292..0f4a8677 100644 --- a/silhouette/Graphtec.py +++ b/silhouette/Graphtec.py @@ -689,35 +689,40 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, offset = (offset, 0) s.write("FU%d,%d\x03" % (height-top, width-left)) - s.write("FN0\x03") # // ? + s.write("FN0\x03") # Orientation of coordinate system 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("TB52,2\x03") #type of regmarks: 0='Original,SD', 2='Cameo,Portrait' + s.write("TB51,400\x03") # length of regmarks + s.write("TB53,10\x03") # width of regmarks s.write("TB55,1\x03") if regsearch: - cmd="123" + # automatic regmark test, height, width, top, left + s.write("TB123,%i,%i,118,18\x03" % (reglength * 20.0, regwidth * 20.0)) 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)) + # manual regmark, height, width + s.write("TB23,%i,%i\x03" % (reglength * 20.0, regwidth * 20.0)) - s.write("FQ5\x03") ## only with registration ??? + #while True: + # s.write("\1b\05") #request status + # resp = s.read(timeout=1000) + # if resp != " 1\x03": + # break; + 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 != " 0\x03": + #raise ValueError("Couldn't find registration marks. (2)(%s)" % str(resp)) #resp = s.read(timeout=40000) ## Allow 20s for reply... #if resp != " 1\x03": - #raise ValueError("Couldn't find registration marks.") + #raise ValueError("Couldn't find registration marks. (3)") else: s.write("TB50,1\x03") # ??? @@ -725,6 +730,7 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, s.write("FO%d\x03" % (height-top)) p = "&100,100,100,\\0,0,Z%d,%d,L0" % (width,height) # scale + #p = "\\0,0\x03Z%d,%d\x03" % (width,height) # scale bbox['clip'] = {'urx':width, 'ury':top, 'llx':left, 'lly':height} bbox['only'] = bboxonly From 5908bdc9ea9036e0e8b04b6fb5c76e424e94f336 Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Tue, 21 Jun 2016 18:54:13 +0200 Subject: [PATCH 05/12] Added comments Corrected some typos --- silhouette/Graphtec.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/silhouette/Graphtec.py b/silhouette/Graphtec.py index 0d9c0387..0396acd0 100644 --- a/silhouette/Graphtec.py +++ b/silhouette/Graphtec.py @@ -405,11 +405,27 @@ def initialize(s): pass # Additional commands seen in init by Silhouette Studio + #s.write("[\x03") # asks for something, no idea, just repeating sniffed communication + #try: + # resp = s.read(timeout=1000) + # if len(resp) > 1: + # print("[: '%s'" % (resp[:-1]), file=s.log) # response '0,0' + #except: + # pass + + #s.write("U\x03") # asks for something, no idea, just repeating sniffed communication + #try: + # resp = s.read(timeout=1000) + # if len(resp) > 1: + # print("U: '%s'" % (resp[:-1]), file=s.log) # response '20320,4120' max. print range? + #except: + # pass + #s.write("FQ0\x03") # asks for something, no idea, just repeating sniffed communication #try: # resp = s.read(timeout=1000) # if len(resp) > 1: - # print("FQ0: '%s'" % (resp[:-1]), file=s.log) + # print("FQ0: '%s'" % (resp[:-1]), file=s.log) # response '10' #except: # pass @@ -417,7 +433,7 @@ def initialize(s): #try: # resp = s.read(timeout=1000) # if len(resp) > 1: - # print("FQ2: '%s'" % (resp[:-1]), file=s.log) + # print("FQ2: '%s'" % (resp[:-1]), file=s.log) # response '18' #except: # pass @@ -433,7 +449,7 @@ def initialize(s): #try: # resp = s.read(timeout=1000) # if len(resp) > 1: - # print("FA: '%s'" % (resp[:-1]), file=s.log) + # print("FA: '%s'" % (resp[:-1]), file=s.log) # response '0,0' #except: # pass @@ -530,7 +546,7 @@ def setup(s, media=132, speed=None, pressure=None, pen=None, trackenhancing=Fals s.write("FE0,0\x03") def find_bbox(s, cut): - """Find the bouding box of the cut, returns (xmin,ymin,xmax,ymax)""" + """Find the bounding box of the cut, returns (xmin,ymin,xmax,ymax)""" bb = {} for path in cut: for pt in path: @@ -727,7 +743,7 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, offset = (offset, 0) if regmark: - s.write("TB50,0\x03") #only with registration (it was TB50,1) ??? + s.write("TB50,0\x03") #only with registration (it was TB50,1), landscape mode s.write("TB99\x03") s.write("TB52,2\x03") #type of regmarks: 0='Original,SD', 2='Cameo,Portrait' s.write("TB51,400\x03") # length of regmarks @@ -780,7 +796,7 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, p = '\x03'.join(cmd_list) if bboxonly == True: - # move the bouding box + # move the bounding box p = "M%d,%d" % (int(0.5+bbox['ury']), int(0.5+bbox['llx'])) p += "\x03D%d,%d" % (int(0.5+bbox['ury']), int(0.5+bbox['urx'])) p += "\x03D%d,%d" % (int(0.5+bbox['lly']), int(0.5+bbox['urx'])) From 9f52430be04421a0ea6781dfdb7b00d6d9f0d55a Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Tue, 21 Jun 2016 19:03:56 +0200 Subject: [PATCH 06/12] Added a possibility to compensate the offset of the registration mark to svg document origin. --- sendto_silhouette.inx | 2 ++ sendto_silhouette.py | 12 +++++++++--- silhouette/Graphtec.py | 11 ++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sendto_silhouette.inx b/sendto_silhouette.inx index 4973afb5..ca2fd83e 100644 --- a/sendto_silhouette.inx +++ b/sendto_silhouette.inx @@ -64,6 +64,8 @@ Pressure values of 19 or more make the machine misbehave. Beware. Search for the registration marks automatically. Seems on some devices there is another mode, where you can set the references manually. 180 230 + 15 + 20 Distance of the registration mark edges diff --git a/sendto_silhouette.py b/sendto_silhouette.py index 8a5ec037..caefe0c3 100644 --- a/sendto_silhouette.py +++ b/sendto_silhouette.py @@ -305,9 +305,13 @@ def __init__(self): 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]") + type = 'float', dest = 'regwidth', default = 180.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]") + self.OptionParser.add_option('--rego-x', '--regoriginx',action = 'store', + type = 'float', dest = 'regoriginx', default = 15.0, help="X mark origin from left [mm]") + self.OptionParser.add_option('--rego-y', '--regoriginy', action = 'store', + type = 'float', dest = 'regoriginy', default = 20.0, help="X mark origin from top [mm]") def version(self): return __version__ @@ -1022,7 +1026,8 @@ def write_progress(done, total, msg): margintop=0, marginleft=0, 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) + regwidth=self.options.regwidth,reglength=self.options.reglength, + regoriginx=self.options.regoriginx,regoriginy=self.options.regoriginy) if len(bbox['bbox'].keys()): print >>self.tty, "autocrop left=%.1fmm top=%.1fmm" % ( @@ -1037,7 +1042,8 @@ def write_progress(done, total, msg): offset=(self.options.x_off,self.options.y_off), bboxonly=self.options.bboxonly, regmark=self.options.regmark,regsearch=self.options.regsearch, - regwidth=self.options.regwidth,reglength=self.options.reglength) + regwidth=self.options.regwidth,reglength=self.options.reglength, + regoriginx=self.options.regoriginx,regoriginy=self.options.regoriginy) if len(bbox['bbox'].keys()) == 0: print >>self.tty, "empty page?" print >>sys.stderr, "empty page?" diff --git a/silhouette/Graphtec.py b/silhouette/Graphtec.py index 0396acd0..98982947 100644 --- a/silhouette/Graphtec.py +++ b/silhouette/Graphtec.py @@ -688,7 +688,7 @@ def plot_cmds(s, plist, bbox, x_off_mm, y_off_mm): def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, marginleft=None, pathlist=None, offset=None, bboxonly=False, end_paper_offset=0, regmark=False, regsearch=False, - regwidth=180, reglength=230): + regwidth=180, reglength=230, regoriginx=15.0, regoriginy=20.0): """plot sends the pathlist to the device (real or dummy) and computes the bounding box of the pathlist, which is returned. @@ -743,6 +743,15 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, offset = (offset, 0) if regmark: + # after registration logically (0,0) is at regmark position + # compensate the offset of the regmark to the svg document origin. + #bb = s.find_bbox(pathlist) + #print("bb llx=%g ury=%g" % (bb['llx'], bb['ury']), file=s.log) + #regoriginx = bb['llx'] + #regoriginy = bb['ury'] + print("bb regoriginx=%g regoriginy=%g" % (regoriginx, regoriginy), file=s.log) + offset = (offset[0] - regoriginx, offset[1] - regoriginy) + s.write("TB50,0\x03") #only with registration (it was TB50,1), landscape mode s.write("TB99\x03") s.write("TB52,2\x03") #type of regmarks: 0='Original,SD', 2='Cameo,Portrait' From 075474e44d93e4673f0efbc39351c00a8efcf5a4 Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Tue, 21 Jun 2016 19:05:10 +0200 Subject: [PATCH 07/12] Clarify info text for registration mark position --- sendto_silhouette.inx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sendto_silhouette.inx b/sendto_silhouette.inx index ca2fd83e..4b04bf1e 100644 --- a/sendto_silhouette.inx +++ b/sendto_silhouette.inx @@ -64,8 +64,8 @@ Pressure values of 19 or more make the machine misbehave. Beware. Search for the registration marks automatically. Seems on some devices there is another mode, where you can set the references manually. 180 230 - 15 - 20 + 15 + 20 Distance of the registration mark edges From 16fc0c25988af10a94a928daabd120cd22dfd8be Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Tue, 21 Jun 2016 19:09:04 +0200 Subject: [PATCH 08/12] Start regmark search at expected position. Limit cutting area inside regmarks. --- silhouette/Graphtec.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/silhouette/Graphtec.py b/silhouette/Graphtec.py index 98982947..353a8943 100644 --- a/silhouette/Graphtec.py +++ b/silhouette/Graphtec.py @@ -752,6 +752,10 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, print("bb regoriginx=%g regoriginy=%g" % (regoriginx, regoriginy), file=s.log) offset = (offset[0] - regoriginx, offset[1] - regoriginy) + # Limit the cutting area inside cutting marks + height = reglength * 20.0 + width = regwidth * 20.0 + s.write("TB50,0\x03") #only with registration (it was TB50,1), landscape mode s.write("TB99\x03") s.write("TB52,2\x03") #type of regmarks: 0='Original,SD', 2='Cameo,Portrait' @@ -761,7 +765,8 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, if regsearch: # automatic regmark test, height, width, top, left - s.write("TB123,%i,%i,118,18\x03" % (reglength * 20.0, regwidth * 20.0)) + # add a search range of 10mm + s.write("TB123,%i,%i,%i,%i\x03" % (reglength * 20.0, regwidth * 20.0, (regoriginy - 10) * 20.0, (regoriginx - 10) * 20.0)) else: # manual regmark, height, width s.write("TB23,%i,%i\x03" % (reglength * 20.0, regwidth * 20.0)) From 7bfd7090eaaa1b0a6484fa8331b464cc0411780b Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Thu, 11 Aug 2016 13:51:21 +0200 Subject: [PATCH 09/12] Some corrections and improvements to the regmarks template. * Position of the regmarks correctedd. (They were slightly off, leading to parallelograms) * Width of the regmarks set to 0.5mm, this is hardcoded in sourcecode * Named the regmarks with IDs * Created an extra layer for the regmarks. --- examples/registration-marks.svg | 159 +++++++++++++++++++++----------- 1 file changed, 105 insertions(+), 54 deletions(-) diff --git a/examples/registration-marks.svg b/examples/registration-marks.svg index 9373bc2c..17712a33 100644 --- a/examples/registration-marks.svg +++ b/examples/registration-marks.svg @@ -14,9 +14,7 @@ id="svg2" version="1.1" inkscape:version="0.48.4 r9939" - sodipodi:docname="Silhouette-Passermarken.svg"> - + sodipodi:docname="registration-marks.svg"> + spacingx="1mm" + units="mm" + snapvisiblegridlinesonly="true" + enabled="true" + visible="true" + empspacing="5" + id="grid4328" + type="xygrid" /> + @@ -58,62 +58,113 @@ image/svg+xml - + + inkscape:label="Regmarks"> + width="17.716536" + id="regmark-tl" + style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1.77165354;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + inkscape:label="regmark-bl" + inkscape:connector-curvature="0" + id="regmark-bl" + d="m 124.01575,885.82675 -70.866144,0 0,-70.86614" + style="fill:none;stroke:#000000;stroke-width:1.77165353;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> 230mm + id="tspan4332" + sodipodi:role="line">230mm 180mm + sodipodi:role="line">180mm + d="m 372.04724,70.86612 0,-17.716536 -7.08661,0 14.17323,-10.629921 14.17323,10.629921 -7.08662,0 0,17.716536 z" + style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + + + 15mm + 20mm + + From 9380b145421e390f39ffca70976e3d2de3923b9f Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Thu, 11 Aug 2016 14:06:00 +0200 Subject: [PATCH 10/12] Added instructions for how to use the registration marks to the readme. --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index ea13e8fc..e717146c 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,21 @@ Troubleshooting If this reports no usb.core.Device to you, please help troubleshoot. +Using of registration marks +--------------------------- + +To plot with registration marks do the following: + +1. Open the document examples/registration-marks.svg +2. Insert your cutting paths and graphics on the apropriate layers. +3. Printout the whole document including registration marks. You probably want to hide the cutting layer. +4. Select your cutting paths in the document, but exclude regmarks and graphics. +5. Set or ensure the correct values (regmark position/width/height) on the regmark tab. +6. Enable 'Document has registration marks' and 'Search for registration marks' +7. Start cut. + +The plotter will search the registration marks at the given positions. If it founds the marks, they will serve as accurate reference and define the origin. Therefore it is necessary to set the correct offset values of the mark. As a result the cut will go precisely along the graphics. +At my device there seems to be a little offset between the search optics and the cutting knife. For enhanced precision I have to set an offset of 0,1mm for both x and y on the first tab to compensate. Features -------- From 402074ff218376360b57ebe38405a25a62f75cdf Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Tue, 11 Oct 2016 19:03:40 +0200 Subject: [PATCH 11/12] Added another template for registration marks using a whole A4 sheet. --- examples/registration-marks-a4-maxi.svg | 170 ++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 examples/registration-marks-a4-maxi.svg diff --git a/examples/registration-marks-a4-maxi.svg b/examples/registration-marks-a4-maxi.svg new file mode 100644 index 00000000..9b990993 --- /dev/null +++ b/examples/registration-marks-a4-maxi.svg @@ -0,0 +1,170 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + 284mm + 198mm + + + + 6mm + 7mm + + + + From dd16493b0331c1f0926a3e9434a37f2574d2c0c0 Mon Sep 17 00:00:00 2001 From: Johann Gail Date: Sat, 3 Dec 2016 13:32:53 +0100 Subject: [PATCH 12/12] Limited the input range of regmark origin to least 10.0mm --- sendto_silhouette.inx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sendto_silhouette.inx b/sendto_silhouette.inx index f85aaa3d..5bd844af 100644 --- a/sendto_silhouette.inx +++ b/sendto_silhouette.inx @@ -64,8 +64,8 @@ Pressure values of 19 or more make the machine misbehave. Beware. Search for the registration marks automatically. Seems on some devices there is another mode, where you can set the references manually. 180 230 - 15 - 20 + 15 + 20 Distance of the registration mark edges