From e87a749d4b3d3ef759a87c402721bc861902f035 Mon Sep 17 00:00:00 2001 From: Alexander Senger Date: Thu, 10 Mar 2016 17:54:21 +0100 Subject: [PATCH] add choice of head position after cutting (with GUI option) --- sendto_silhouette.inx | 5 +++++ sendto_silhouette.py | 7 +++++-- silhouette/Graphtec.py | 24 +++++++++++++----------- 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/sendto_silhouette.inx b/sendto_silhouette.inx index b71b1cbd..0d70eacf 100644 --- a/sendto_silhouette.inx +++ b/sendto_silhouette.inx @@ -52,6 +52,11 @@ To see the used area, tick the checkmark above and use pressure=1 (or better remove tool) 1 false + + Start Position + Below Cut-Out + + Choose position of blade relative to the media after cutting. "Below Cut-Out" is ideal for using cross-cutter. diff --git a/sendto_silhouette.py b/sendto_silhouette.py index 95ead6bb..c1a94c79 100644 --- a/sendto_silhouette.py +++ b/sendto_silhouette.py @@ -271,6 +271,9 @@ 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('-e', '--endposition', '--end-postition', + '--end_position', action = 'store', choices=('start','below'), + dest = 'endposition', default = 'below', help="Position of head after cutting: start or below") def version(self): return __version__ @@ -978,7 +981,7 @@ 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, endposition='start') # only return the bbox, do not draw it. if len(bbox['bbox'].keys()): print >>self.tty, "autocrop left=%.1fmm top=%.1fmm" % ( bbox['bbox']['llx']*bbox['unit'], @@ -990,7 +993,7 @@ 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, endposition=self.options.endposition) 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 fc7bb1bf..2b62ec91 100644 --- a/silhouette/Graphtec.py +++ b/silhouette/Graphtec.py @@ -673,7 +673,7 @@ 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): + def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, marginleft=None, pathlist=None, offset=None, bboxonly=False, end_paper_offset=10, endposition='below'): """plot sends the pathlist to the device (real or dummy) and computes the bounding box of the pathlist, which is returned. @@ -688,10 +688,13 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, marginleft=None bboxonly: True for drawing the bounding instead of the actual cut design; None for not moving at all (just return the bounding box). Default: False for normal cutting or drawing. - end_paper_offset: [mm] adds to the final move, if return_home was False in setup. + end_paper_offset: [mm] adds to the final move, if endposition is 'below'. If the end_paper_offset is negative, the end position is within the drawing (reverse movmeents are clipped at the home position) It reverse over the last home position. + endpostiton: Default 'below': The media is moved to a position below the actual cut (so another + can be started without additional steps, also good for using the cross-cutter). + 'start': The media is returned to the positon where the cut started. Example: The letter Y (20mm tall, 9mm wide) can be generated with pathlist=[[(0,0),(4.5,10),(4.5,20)],[(9,0),(4.5,10)]] """ @@ -752,8 +755,8 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, marginleft=None p += "\x03D%d,%d" % (int(0.5+bbox['lly']), int(0.5+bbox['llx'])) p += "\x03D%d,%d" % (int(0.5+bbox['ury']), int(0.5+bbox['llx'])) p += "\x03" # Properly terminate string of plot commands. - - trailer = [] + # potentially long command string needs extra care + s.safe_write(p) # Silhouette Cameo2 does not start new job if not properly parked on left side # Attention: This needs the media to not extend beyond the left stop @@ -761,18 +764,17 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=None, marginleft=None if not 'lly' in bbox: bbox['lly'] = 0 if not 'urx' in bbox: bbox['urx'] = 0 if not 'ury' in bbox: bbox['ury'] = 0 - new_home = "M%d,%d\x03SO0\x03" % (int(0.5+bbox['lly']+end_paper_offset*20.), 0) - - - # potentially long command string needs extra care - s.safe_write(p) - + if endposition == 'start': + new_home = "H\x03" + else: #includes 'below' + new_home = "M%d,%d\x03SO0\x03" % (int(0.5+bbox['lly']+end_paper_offset*20.), 0) #! axis swapped when using Cameo-system + #new_home += "FN0\x03TB50,0\x03" s.write(new_home) return { 'bbox': bbox, 'unit' : 1/20., - 'trailer': trailer + 'trailer': new_home }