Skip to content

Commit

Permalink
Merged third commit of pull request #25 from Alexander Wenger.
Browse files Browse the repository at this point in the history
Comment from the author:
In GUI and plot code an option is implemented to chose the end position of the blade after cutting. This can be useful for some jobs. There was already some code which seemed to be intended for this purpose but was left unfinished. Frankly, I had some difficulties understanding the logic and implemented my own approach.
  • Loading branch information
EtherGraf committed Jan 16, 2017
2 parents e002344 + e87a749 commit 75d3a7f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions sendto_silhouette.inx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ Pressure values of 19 or more make the machine misbehave. Beware.
<param name="bbox_help" type="description">To see the used area, tick the checkmark above and use pressure=1 (or better remove tool)</param>
<param name="multipass" type="int" min="1" max="8" _gui-text="Repeat each stroke">1</param>
<param name="reversetoggle" type="boolean" _gui-text="Cut in opposite direction(s)">false</param>
<param name="endposition" type="enum" _gui-text="Position After Cutting:">
<item value="start">Start Position</item>
<item value="below">Below Cut-Out</item>
</param>
<param name="endposition_help" type="description">Choose position of blade relative to the media after cutting. "Below Cut-Out" is ideal for using cross-cutter.</param>
</page>

<page name='reg' _gui-text='Regmarks'>
Expand Down
5 changes: 5 additions & 0 deletions sendto_silhouette.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,9 @@ def __init__(self):
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]")
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__
Expand Down Expand Up @@ -1030,6 +1033,7 @@ def write_progress(done, total, msg):
mediaheight=px2mm(self.docHeight),
margintop=0, marginleft=0,
bboxonly=None, # only return the bbox, do not draw it.
endposition='start', # only return the bbox, do not draw it.
regmark=self.options.regmark,regsearch=self.options.regsearch,
regwidth=self.options.regwidth,reglength=self.options.reglength)

Expand All @@ -1045,6 +1049,7 @@ def write_progress(done, total, msg):
mediaheight=px2mm(self.docHeight),
offset=(self.options.x_off,self.options.y_off),
bboxonly=self.options.bboxonly,
endposition=self.options.endposition,
regmark=self.options.regmark,regsearch=self.options.regsearch,
regwidth=self.options.regwidth,reglength=self.options.reglength)
if len(bbox['bbox'].keys()) == 0:
Expand Down
25 changes: 15 additions & 10 deletions silhouette/Graphtec.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# (c) 2013,2014 [email protected]
# (c) 2016 [email protected]
# (c) 2016 Alexander Wenger
# (c) 2017 Johann Gail
#
# Distribute under GPLv2 or ask.
#
Expand Down Expand Up @@ -719,7 +721,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,
end_paper_offset=0, endposition='below', 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 All @@ -735,10 +737,13 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=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)]]
"""
Expand Down Expand Up @@ -830,26 +835,26 @@ def plot(s, mediawidth=210.0, mediaheight=297.0, margintop=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
if not 'llx' in bbox: bbox['llx'] = 0 # survive empty pathlist
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
}


Expand Down

0 comments on commit 75d3a7f

Please sign in to comment.