kurse:efcomputergrafik:kw48

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
kurse:efcomputergrafik:kw48 [2019/11/27 11:01]
Ivo Blöchliger [Umgang mit Inkscape]
kurse:efcomputergrafik:kw48 [2019/12/04 11:48]
Ivo Blöchliger
Line 102: Line 102:
  
 ===== Umgang mit Inkscape ===== ===== Umgang mit Inkscape =====
 +
 +Download für die Schulcomputer: https://fginfo.ksbg.ch/dokuwiki/doku.php?id=lehrkraefte:blc:informatik:glf19:glf19#make_the_computer_zimmer_great_again
 +
 Nützliche Tastenkombinationen: Nützliche Tastenkombinationen:
   * F1: Auswahlmodus (zum kopieren, löschen, verschieben, rotieren)   * F1: Auswahlmodus (zum kopieren, löschen, verschieben, rotieren)
-  * F2: Edit-Modus (Manipulation der Pfadelemente.+  * F2: Edit-Modus (Manipulation der Pfadelemente).
  
 Pfad-Manipulationen: Pfad-Manipulationen:
Line 123: Line 126:
 if (position!=-1): # Wirklich was gefunden if (position!=-1): # Wirklich was gefunden
   # tu was damit   # tu was damit
 +</code>
 +=== Substring ===
 +<code python>
 +a="0123456789"
 +a[2:5] # -> liefert "234"
 +</code>
 +=== Text Analyse ===
 +Ist der Path-String einmal gefunden, geht es darum, diesen zu analysieren. Als erster Schritt soll dieser nach Leerschlägen aufgeteilt werden:
 +<code python>
 +txt = "foo bar baz boo"
 +items = txt.split(" ")
 </code> </code>
  
-===== G-Code für den Plotter ===== +=== Convertierung in Zahlen === 
-Der Nullpunkt befindet sich bei den Radien $r_1=r_2=1445$ (in mm)Pro Motorschritt verändern sich die Radien um $\approx 0.0157029$ (mm). Die Motoren haben einen Abstand von 1930 mm.+<code python> 
 +zahl float("3.14") 
 +</code>
  
-Der G-Code bezieht sich direkt auf die Motorenschritte (was eigentlich gerade nicht der Sinn von G-Code ist). 
  
-Nur G1 (lineare Interpolation) ist implementiert: +<hidden converter.py> 
-  * G1 X-400 Y800  (Gehe zur absoluten Position -400 Schritte (Motor links) und +800 Schritte (Motor rechts)+<code python converter.py>
-  * G1 Z0 (Stift hoch, nicht zeichnen) +
-  * G1 Z1 (Stift runter, zeichnen) +
-Nach jedem Kommando muss auf ein 'OK\n' gewartet werden.+
  
 +def convert(elements):
 +    # Aktuelle Koordinaten
 +    x = 0
 +    y = 0
 +    # Position im elements Array
 +    e = 0
 +    # letztes Kommando
 +    lastCMD = ""
 +    while e < len(elements):
 +        if elements[e]=="M":  # Move absolute
 +            x = float(elements[e+1])
 +            y = float(elements[e+2])
 +            e = e+3   # 3 Element konsumiert
 +        elif elements[e]=="m":  # Move relative
 +            x = x + float(elements[e+1])
 +            y = y + float(elements[e+2])
 +            e = e+3   # 3 Element konsumiert
 +
 +
 +
 +with open('text.svg', 'r') as content_file:
 +    content = content_file.read()
 +    
 +# print(content)
 +# Anfangsposition vom path
 +position = content.find("<path")
 +if position<0:
 +    raise BaseException("Kein <path gefunden!")
 +
 +#print("Position %d" % position)
 +# Erste 20 Zeichen vom path
 +#print(content[position:(position+20)])
 +
 +# d=" suchen... (ab der Position position)
 +while True:
 +    position = content.find("d=\"", position)
 +    if position<0:
 +        BaseException("Kein d= gefunden")
 +        
 +    if content[position-1]<'0': # kein Buchstabe vor d
 +        break
 +    
 +    position+=1
 +# Erste 20 Zeichen vom d
 +
 +start = position+3
 +ende = content.find("\"", start)
 +
 +pfaddef = content[start:ende]
 +print(pfaddef)
 +pfaddef = pfaddef.replace(",", " ")
 +print(pfaddef)
 +elemente = pfaddef.split(" ")
 +print(elemente)
 +
 +</code>
 +</hidden>
  
  • kurse/efcomputergrafik/kw48.txt
  • Last modified: 2019/12/04 11:48
  • by Ivo Blöchliger