dev.wait_for_ready()
  time.sleep(2)	# show the time before doing something else.
  cy_off += int(ystep*1.2)

  if 'cmd_idx' in doing:
    ret_cmd = doing['cmds'][doing['cmd_idx']]+','
    # we want to repeat the last draw command as a move command when returning.
    if ret_cmd[0] == 'D': ret_cmd = 'M'+ret_cmd[1:]
    dev.write(ret_cmd)
  now=time.time()

  while (now < when):
    # something else, interruptable
    if not 'name' in doing and len(todo)  and todo_needs_origin_moved == 0:
      doing['name'] = todo.pop(0)
      doing['data'] = dev.load_dumpfile(doing['name'])
      doing['cmd_idx'] = -1
      if doing['data'] is None:
        del(doing['cmd_idx'])
        del(doing['name'])
      else:
        doing['cmds'] = dev.plot_cmds(doing['data'], meta['bbox'], clock_margin, 0) # keep space for the clock

    if 'cmd_idx' in doing:
      doing['cmd_idx'] += 1
      if doing['cmd_idx'] < len(doing['cmds']):
        dev.write(doing['cmds'][doing['cmd_idx']]+',')
      else:
        for key in doing.keys(): del(doing[key])
        time.sleep(1)
        print("sleep(%f)" % (when-now))
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'])
dev.wait_for_ready()
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']))
dev.wait_for_ready()
Exemple #4
0
    dev.wait_for_ready()
    time.sleep(2)  # show the time before doing something else.
    cy_off += int(ystep * 1.2)

    if 'cmd_idx' in doing:
        ret_cmd = doing['cmds'][doing['cmd_idx']] + ','
        # we want to repeat the last draw command as a move command when returning.
        if ret_cmd[0] == 'D': ret_cmd = 'M' + ret_cmd[1:]
        dev.write(ret_cmd)
    now = time.time()

    while (now < when):
        # something else, interruptable
        if not 'name' in doing and len(todo) and todo_needs_origin_moved == 0:
            doing['name'] = todo.pop(0)
            doing['data'] = dev.load_dumpfile(doing['name'])
            doing['cmd_idx'] = -1
            if doing['data'] is None:
                del (doing['cmd_idx'])
                del (doing['name'])
            else:
                doing['cmds'] = dev.plot_cmds(doing['data'], meta['bbox'],
                                              clock_margin,
                                              0)  # keep space for the clock

        if 'cmd_idx' in doing:
            doing['cmd_idx'] += 1
            if doing['cmd_idx'] < len(doing['cmds']):
                dev.write(doing['cmds'][doing['cmd_idx']] + ',')
            else:
                for key in doing.keys():
    time.sleep(2)  # show the time before doing something else.
    cy_off += int(ystep * 1.2)

    if "cmd_idx" in doing:
        ret_cmd = doing["cmds"][doing["cmd_idx"]] + ","
        # we want to repeat the last draw command as a move command when returning.
        if ret_cmd[0] == "D":
            ret_cmd = "M" + ret_cmd[1:]
        dev.write(ret_cmd)
    now = time.time()

    while now < when:
        # something else, interruptable
        if not "name" in doing and len(todo) and todo_needs_origin_moved == 0:
            doing["name"] = todo.pop(0)
            doing["data"] = dev.load_dumpfile(doing["name"])
            doing["cmd_idx"] = -1
            if doing["data"] is None:
                del (doing["cmd_idx"])
                del (doing["name"])
            else:
                doing["cmds"] = dev.plot_cmds(doing["data"], meta["bbox"], clock_margin, 0)  # keep space for the clock

        if "cmd_idx" in doing:
            doing["cmd_idx"] += 1
            if doing["cmd_idx"] < len(doing["cmds"]):
                dev.write(doing["cmds"][doing["cmd_idx"]] + ",")
            else:
                for key in doing.keys():
                    del (doing[key])
                time.sleep(1)