# import sys sys.path.append('/usr/share/inkscape/extensions') sys.path.append('/home/testy/src/github/inkscape-silhouette') from silhouette.Graphtec import SilhouetteCameo __version__ = '0.1' __author__ = 'Juergen Weigert <*****@*****.**>' k = 0.2 # knive-center offset, (0.1 is not enough) test_sq_tr = \ [ [(4+k, 5+k), (2, 3), (2, 1), (3, 1), (9, 5), (3, 9), (2, 9), (2, 7), (4+k, 5-k)], [(0, 0), (0, 10), (10, 10), (10, 0), (0, 0-k)] ] def write_progress(done, total, msg): perc = 100. * done / total print("%d%% %s\r" % (perc, msg)) dev = SilhouetteCameo(progress_cb=write_progress, no_device=False) state = dev.status() # hint at loading paper, if not ready. print "status=%s" % (state) print "device version: '%s'" % dev.get_version() dev.setup(media=132, pen=False, pressure=1, speed=10) dev.plot(pathlist=test_sq_tr, offset=(30, 30))
#! /usr/bin/python # # simple demo program to feed paper in the silhouette cameo. # (C) 2015 [email protected] # # Requires: python-usb # from Factory from __future__ import print_function import sys sys.path.extend(['..', '.']) # make it callable from top or misc directory. from silhouette.Graphtec import SilhouetteCameo dev = SilhouetteCameo() # no dev.setup() needed here. feed_mm = 10 if len(sys.argv) > 1: feed_mm = float(sys.argv[1]) if not feed_mm: print("Usage: %s [PAPER_FORWARD_MM]" % sys.argv[0]) dev.move_origin(feed_mm)
# Requires: python-usb # from Factory from __future__ import print_function import time, sys, os sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..') # make it callable from anywhere from silhouette.Graphtec import SilhouetteCameo # coordinates in mm, origin int top lefthand corner arrow1 = [(0, 5), (21, 5), (18, 0), (31, 10), (18, 20), (21, 15), (0, 15), (3, 10), (0, 5)] arrow2 = [(x[0] + 263, x[1] + 0) for x in arrow1] arrow3 = [(x[0] + 30, x[1] + 0) for x in arrow1] dev = SilhouetteCameo() print("status=%s" % dev.wait_for_ready(20)) tmp_fwd = 85 # enough to show 20mm of the latest drawing on the far side of the device. dev.setup(media=113, pressure=0, trackenhancing=True) for i in range(8): bbox = dev.plot(pathlist=[arrow1, [(0, tmp_fwd), (0, tmp_fwd)]], mediaheight=180, offset=(60, 0), bboxonly=False, end_paper_offset=-tmp_fwd + 1) dev.wait_for_ready() print(i, "path done.") time.sleep(5)
# Requires: sudo easy_install freetype-py # # Modelled after https://github.com/rougier/freetype-py/blob/master/examples/glyph-vector.py # first working draft, doing 2 things at a time. import sys,time,gtk from goocanvas import * import cairo,random import freetype import matplotlib.path as MP import matplotlib.transforms as MT sys.path.extend(['..','.']) # make it callable from top or misc directory. from silhouette.Graphtec import SilhouetteCameo dev = SilhouetteCameo() dev.setup(media=113, pressure=1, trackenhancing=True, return_home=True) # 113 = Pen time_window=60 # show the clock every N seconds. clock_margin=30 # mm kept clear for clock fontfile= 'ttf/RIKY2vamp.ttf' # 15sec, 55x11mm, nice script. #fontfile= 'ttf/Channel.ttf' # 18sec, 80x17mm, very round. stylish. #fontfile= 'ttf/LeckerliOne-Regular.ttf' # 25sec, 88x39mm, vert stretched upper half, nicely rounded. #fontfile= 'ttf/WC Wunderbach Wimpern.ttf' # 78sec, 82x20mm, fantastic stencil #fontfile= 'ttf/FreeSans.ttf' # 19sec, 73x14mm, vertical metric is much too high #fontfile= '/usr/share/fonts/truetype/FreeSans.ttf' # 17sec, 73x14mm, glyph ZERO is damaged. #fontfile= 'ttf/motorhead.ttf' # 17sec, 75x30mm, glyph 1 horizontally off. def translate_poly(poly,xoff,yoff,scale=1): tuplepath=[]
# Modelled after https://github.com/rougier/freetype-py/blob/master/examples/glyph-vector.py # first working draft, doing 2 things at a time. from __future__ import print_function import sys, time, gtk from goocanvas import * import cairo, random import freetype import matplotlib.path as MP import matplotlib.transforms as MT sys.path.extend(['..', '.']) # make it callable from top or misc directory. from silhouette.Graphtec import SilhouetteCameo dev = SilhouetteCameo() dev.setup(media=113, pressure=1, trackenhancing=True, return_home=True) # 113 = Pen time_window = 60 # show the clock every N seconds. clock_margin = 30 # mm kept clear for clock fontfile = 'ttf/RIKY2vamp.ttf' # 15sec, 55x11mm, nice script. #fontfile= 'ttf/Channel.ttf' # 18sec, 80x17mm, very round. stylish. #fontfile= 'ttf/LeckerliOne-Regular.ttf' # 25sec, 88x39mm, vert stretched upper half, nicely rounded. #fontfile= 'ttf/WC Wunderbach Wimpern.ttf' # 78sec, 82x20mm, fantastic stencil #fontfile= 'ttf/FreeSans.ttf' # 19sec, 73x14mm, vertical metric is much too high #fontfile= '/usr/share/fonts/truetype/FreeSans.ttf' # 17sec, 73x14mm, glyph ZERO is damaged. #fontfile= 'ttf/motorhead.ttf' # 17sec, 75x30mm, glyph 1 horizontally off.
from silhouette.Graphtec import SilhouetteCameo ArgParser = argparse.ArgumentParser(description='Cut a dumpfile from sendto_silhouette without using inkscape.') ArgParser.add_argument('-P', '--pen', action='store_true', help="switch to pen mode. Default: knive mode") ArgParser.add_argument('-b', '--bbox', action='store_true', help="Bounding box only. Default: entire design") ArgParser.add_argument('-x', '--xoff', type=float, default=0.0, help="Horizontal offset [mm]. Positive values point rightward") ArgParser.add_argument('-y', '--yoff', type=float, default=0.0, help="Vertical offset [mm]. Positive values point downward") #ArgParser.add_argument('-S', '--scale',type=float, default=1.0, help="Scale the design.") ArgParser.add_argument('-p', '--pressure', type=int, default=3, help="Pressure value [1..18]") ArgParser.add_argument('-s', '--speed', type=int, default=10, help="Speed value [1..10]") ArgParser.add_argument('-W', '--width', type=float, default=210.0, help="Media width [mm].") ArgParser.add_argument('-H', '--height', type=float, default=297.0, help="Media height [mm].") ArgParser.add_argument('dumpfile') args = ArgParser.parse_args() dev = SilhouetteCameo() dev.setup(speed=args.speed, pressure=args.pressure, pen=args.pen) # print args dumpdata=dev.load_dumpfile(args.dumpfile) dev.wait_for_ready() meta = dev.plot(pathlist=[], bboxonly=args.bbox, mediawidth=args.width, mediaheight=args.height, offset=(args.xoff,args.yoff)) print(meta) dev.wait_for_ready() cmd_list = dev.plot_cmds(dumpdata, meta['bbox'], args.xoff, args.yoff) dev.send_command(cmd_list) dev.send_command(meta['trailer'])
# Arrow head. The outer square is an ordinary 1cm x 1cm square. # import sys sys.path.append('/usr/share/inkscape/extensions') sys.path.append('/home/testy/src/github/inkscape-silhouette') from silhouette.Graphtec import SilhouetteCameo __version__ = '0.1' __author__ = 'Juergen Weigert <*****@*****.**>' k=0.2 # knive-center offset, (0.1 is not enough) test_sq_tr = \ [ [(4+k, 5+k), (2, 3), (2, 1), (3, 1), (9, 5), (3, 9), (2, 9), (2, 7), (4+k, 5-k)], [(0, 0), (0, 10), (10, 10), (10, 0), (0, 0-k)] ] def write_progress(done, total, msg): perc = 100.*done/total print("%d%% %s\r" % (perc, msg)) dev = SilhouetteCameo(progress_cb=write_progress, no_device=False) state = dev.status() # hint at loading paper, if not ready. print "status=%s" % (state) print "device version: '%s'" % dev.get_version() dev.setup(media=132, pen=False, pressure=1, speed=10) dev.plot(pathlist=test_sq_tr, offset=(30, 30))
# # Requires: python-usb # from Factory import time, sys, os sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/..') # make it callable from anywhere from silhouette.Graphtec import SilhouetteCameo # coordinates in mm, origin int top lefthand corner arrow1 = [(0, 5), (21, 5), (18, 0), (31, 10), (18, 20), (21, 15), (0, 15), (3, 10), (0, 5)] arrow2 = map(lambda x: (x[0] + 263, x[1] + 0), arrow1) arrow3 = map(lambda x: (x[0] + 30, x[1] + 0), arrow1) dev = SilhouetteCameo() print "status=%s" % dev.wait_for_ready(20) tmp_fwd = 85 # enough to show 20mm of the latest drawing on the far side of the device. dev.setup(media=113, pressure=0, trackenhancing=True, return_home=False) for i in range(8): bbox = dev.plot(pathlist=[arrow1, [(0, tmp_fwd), (0, tmp_fwd)]], mediaheight=180, offset=(60, 0), bboxonly=False, end_paper_offset=-tmp_fwd + 1, no_trailer=True) dev.wait_for_ready() print(i, "path done.")
ArgParser = argparse.ArgumentParser(description='Cut a dumpfile from sendto_silhouette without using inkscape.') ArgParser.add_argument('-P', '--pen', action='store_true', help="switch to pen mode. Default: knive mode") ArgParser.add_argument('-b', '--bbox', action='store_true', help="Bounding box only. Default: entire design") ArgParser.add_argument('-x', '--xoff', type=float, default=0.0, help="Horizontal offset [mm]. Positive values point rightward") ArgParser.add_argument('-y', '--yoff', type=float, default=0.0, help="Vertical offset [mm]. Positive values point downward") #ArgParser.add_argument('-S', '--scale',type=float, default=1.0, help="Scale the design.") ArgParser.add_argument('-p', '--pressure', type=int, default=3, help="Pressure value [1..18]") ArgParser.add_argument('-s', '--speed', type=int, default=10, help="Speed value [1..10]") ArgParser.add_argument('-a', '--advance-origin', action='store_true', help="Set the origin below the design. Default: return home.") ArgParser.add_argument('-W', '--width', type=float, default=210.0, help="Media width [mm].") ArgParser.add_argument('-H', '--height', type=float, default=297.0, help="Media height [mm].") ArgParser.add_argument('dumpfile') args = ArgParser.parse_args() dev = SilhouetteCameo() dev.setup(speed=args.speed, pressure=args.pressure, pen=args.pen, return_home=(not args.advance_origin)) # print args dumpdata=dev.load_dumpfile(args.dumpfile) dev.wait_for_ready() meta = dev.plot(pathlist=[], bboxonly=args.bbox, no_trailer=True, mediawidth=args.width, mediaheight=args.height, offset=(args.xoff,args.yoff)) print meta dev.wait_for_ready() cmd_list = dev.plot_cmds(dumpdata, meta['bbox'], args.xoff, args.yoff) dev.write(','.join(cmd_list)) dev.write(''.join(meta['trailer']))
# simple demo program to drive the silhouette cameo. # (C) 2013 [email protected] # (C) 2015 [email protected] # # Requires: python-usb # from Factory import time,sys sys.path.extend(['..','.']) # make it callable from top or misc directory. from silhouette.Graphtec import SilhouetteCameo # coordinates in mm, origin int top lefthand corner arrow1 = [ (0,5), (21,5), (18,0), (31,10), (18,20), (21,15), (0,15), (3,10), (0,5) ] arrow2 = map(lambda x: (x[0]+263, x[1]+0), arrow1) arrow3 = map(lambda x: (x[0]+30, x[1]+0), arrow1) dev = SilhouetteCameo() print "status=%s" % dev.wait_for_ready(20) tmp_fwd=85 # enough to show 20mm of the latest drawing on the far side of the device. dev.setup(media=113, pressure=0, trackenhancing=True, return_home=False) for i in range(8): bbox = dev.plot(pathlist=[ arrow1,[(0,tmp_fwd),(0,tmp_fwd)] ], mediaheight=180, offset=(60,0), bboxonly=False, end_paper_offset=-tmp_fwd+1, no_trailer=True) dev.wait_for_ready() print(i, "path done.") time.sleep(5) dev.write(''.join(bbox['trailer'])) # something is still wrong after we finish a job. The next job does not draw anything. # we can workaround by sending a dummy job. bbox = dev.plot(pathlist=[ [(0,0),(0,0)] ], offset=(0,0))
action='store_true', help="Set the origin below the design. Default: return home.") ArgParser.add_argument('-W', '--width', type=float, default=210.0, help="Media width [mm].") ArgParser.add_argument('-H', '--height', type=float, default=297.0, help="Media height [mm].") ArgParser.add_argument('dumpfile') args = ArgParser.parse_args() dev = SilhouetteCameo() dev.setup(speed=args.speed, pressure=args.pressure, pen=args.pen, return_home=(not args.advance_origin)) # print args dumpdata = dev.load_dumpfile(args.dumpfile) dev.wait_for_ready() meta = dev.plot(pathlist=[], bboxonly=args.bbox, no_trailer=True, mediawidth=args.width, mediaheight=args.height,
# Requires: sudo easy_install freetype-py # # Modelled after https://github.com/rougier/freetype-py/blob/master/examples/glyph-vector.py # first working draft, doing 2 things at a time. import sys, time, gtk from goocanvas import * import cairo, random import freetype import matplotlib.path as MP import matplotlib.transforms as MT sys.path.extend(["..", "."]) # make it callable from top or misc directory. from silhouette.Graphtec import SilhouetteCameo dev = SilhouetteCameo() dev.setup(media=113, pressure=1, trackenhancing=True, return_home=True) # 113 = Pen time_window = 60 # show the clock every N seconds. clock_margin = 30 # mm kept clear for clock fontfile = "ttf/RIKY2vamp.ttf" # 15sec, 55x11mm, nice script. # fontfile= 'ttf/Channel.ttf' # 18sec, 80x17mm, very round. stylish. # fontfile= 'ttf/LeckerliOne-Regular.ttf' # 25sec, 88x39mm, vert stretched upper half, nicely rounded. # fontfile= 'ttf/WC Wunderbach Wimpern.ttf' # 78sec, 82x20mm, fantastic stencil # fontfile= 'ttf/FreeSans.ttf' # 19sec, 73x14mm, vertical metric is much too high # fontfile= '/usr/share/fonts/truetype/FreeSans.ttf' # 17sec, 73x14mm, glyph ZERO is damaged. # fontfile= 'ttf/motorhead.ttf' # 17sec, 75x30mm, glyph 1 horizontally off. def translate_poly(poly, xoff, yoff, scale=1):
#! /usr/bin/python # # simple demo program to feed paper in the silhouette cameo. # (C) 2015 [email protected] # # Requires: python-usb # from Factory import time,sys,string sys.path.extend(['..','.']) # make it callable from top or misc directory. from silhouette.Graphtec import SilhouetteCameo dev = SilhouetteCameo() # no dev.setup() needed here. feed_mm = 10 if len(sys.argv) > 1: feed_mm = string.atof(sys.argv[1]) if not feed_mm: print "Usage: %s [PAPER_FORWARD_MM]" % sys.argv[0] dev.move_origin(feed_mm)