Differences
This shows you the differences between two versions of the page.
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: | ||
+ | |||
Nützliche Tastenkombinationen: | Nützliche Tastenkombinationen: | ||
* F1: Auswahlmodus (zum kopieren, löschen, verschieben, | * F1: Auswahlmodus (zum kopieren, löschen, verschieben, | ||
- | * F2: Edit-Modus (Manipulation der Pfadelemente. | + | * F2: Edit-Modus (Manipulation der Pfadelemente). |
Pfad-Manipulationen: | Pfad-Manipulationen: | ||
Line 123: | Line 126: | ||
if (position!=-1): | if (position!=-1): | ||
# tu was damit | # tu was damit | ||
+ | </ | ||
+ | === Substring === | ||
+ | <code python> | ||
+ | a=" | ||
+ | a[2:5] # -> liefert " | ||
+ | </ | ||
+ | === 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(" | ||
</ | </ | ||
- | ===== G-Code für den Plotter ===== | + | === Convertierung in Zahlen |
- | Der Nullpunkt befindet sich bei den Radien $r_1=r_2=1445$ | + | <code python> |
+ | zahl = float("3.14") | ||
+ | </ | ||
- | 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 ' | + | |
+ | 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]==" | ||
+ | x = float(elements[e+1]) | ||
+ | y = float(elements[e+2]) | ||
+ | e = e+3 # 3 Element konsumiert | ||
+ | elif elements[e]==" | ||
+ | x = x + float(elements[e+1]) | ||
+ | y = y + float(elements[e+2]) | ||
+ | e = e+3 # 3 Element konsumiert | ||
+ | |||
+ | |||
+ | |||
+ | with open(' | ||
+ | content = content_file.read() | ||
+ | | ||
+ | # print(content) | ||
+ | # Anfangsposition vom path | ||
+ | position = content.find("< | ||
+ | if position< | ||
+ | raise BaseException(" | ||
+ | |||
+ | # | ||
+ | # Erste 20 Zeichen vom path | ||
+ | # | ||
+ | |||
+ | # d=" suchen... (ab der Position position) | ||
+ | while True: | ||
+ | position = content.find(" | ||
+ | if position< | ||
+ | BaseException(" | ||
+ | | ||
+ | if content[position-1]<' | ||
+ | break | ||
+ | | ||
+ | position+=1 | ||
+ | # Erste 20 Zeichen vom d | ||
+ | |||
+ | start = position+3 | ||
+ | ende = content.find(" | ||
+ | |||
+ | pfaddef = content[start: | ||
+ | print(pfaddef) | ||
+ | pfaddef = pfaddef.replace(",", | ||
+ | print(pfaddef) | ||
+ | elemente = pfaddef.split(" | ||
+ | print(elemente) | ||
+ | |||
+ | </ | ||
+ | </ | ||