Dies ist eine alte Version des Dokuments!


PLOT YOUR DRAWING

This is about how you could plot your drawings via https://1milliondrawings.com

  1. save the code in a .py script (and yeah install axi / json and requests)
  2. now go and draw some lines @ https://1milliondrawings.com/drawing
  3. after you saved your drawing, remember or write down your DRAWING-ID
  4. now open a terminal and load your script
    1. you will be asked for a drawing-ID
    2. confirm your plot
  5. fun
from axi import Device, Drawing
import json
import requests

################################################
###        by 1milliondrawings.com           ###
###                                          ###
### 1. go to 1milliondrawings.com/drawing    ###
### 2. save your drawing                     ###
### 3. plot your DRAWING-ID                  ###
###                                          ###
################################################

def printer(PATH):
    drawing = Drawing(PATH)
    d = Device()
    d.enable_motors()
    d.run_drawing(drawing)
    d.disable_motors()

def bildprinter(image):
    try:
        url = "https://1milliondrawings.com/axipath?nr="+str(image)
        result = requests.get(url).json()
        resultat = []
        for pfad in result["CORD"]:
            resu = [(piece['x'], piece['y']) for piece in pfad]
            resultat.append(resu)
        print resultat
        plot = raw_input("PLOT IMAGE ID: "+  str(image) +" OR NOT(y/n)")
        if(plot == "y"):
            printer(resultat)
        else:
            Anfang()
    except TypeError:
        print 'PROBLEM: PLEASE TRY AGAIN OR USE OTHER ID'
        Anfang()

def Anfang():
    bildnummer = raw_input("DRAWING NUMBER (#/n): ")
    if(bildnummer == "n"):
        exit()
    else:
        try:
            bildprinter(bildnummer)
        except IOError:
            print 'oops!'

Anfang()

STOP READING

STOP READING - from here down its old news (-31.12.2017)
Here I try to put some research I made together. Main problem: how to print with your axidrawer from within terminal via python scripts… BEST SNIPPET I CAME UP WITH AFTER HOURS

json_encode($yourCordinateArray);

  • art/axidraw.1515681926.txt.gz
  • Zuletzt geändert: 2018/04/24 11:43
  • (Externe Bearbeitung)