REBOL [ Title: "spiralg" author: Sam Neurohack note: "SpiralG" Version: 0.1 ] startangle: 20 angleinc: 30 rayoninc: 0.1 maxiterations: 1800 rayon: 0 zed: 0.8 ;; ;; Generate Gcode file and Start commands ;; make3d: does [ ctime: now/time nom: ajoin ["spiral" now/date ctime/hour "h" ctime/minute "m" ".gcode"] filename: probe to-file nom write/lines filename "M107" write/append filename "^/" write/append filename "M104 S260" ; set temperature write/append filename "^/" write/append filename "G92 X0 Y0 Z0 E0" ;reset extruder write/append filename "^/" write/append filename "M109 S260" ; wait for temperature to be reached write/append filename "^/" write/append filename "G90" ; use absolute coordinates write/append filename "^/" write/append filename "G21" ; set units to millimeters write/append filename "^/" write/append filename "G92 E0" write/append filename "^/" write/append filename "M82" ; use absolute distances for extrusion write/append filename "^/" write/append filename "Z0" ; use absolute distances for extrusion write/append filename "^/" ;; ;; Generate all segments with parameters ;; angle: startangle next360: startangle + 360 for iterations 0 maxiterations 1 [ xpos: rayon * cosine angle ypos: rayon * sine angle print ajoin [" Angle : " angle " X: " xpos " Y: " ypos " angleinc : " angleinc] write/append filename reduce [ajoin ["G1 X" xpos " Y" ypos " E100.0"]] write/append filename "^/" angle: angleinc + angle if angle > next360 [next360: next360 + 360 angleinc: angleinc / 2 rayoninc: rayoninc / 2] rayon: rayon + rayoninc ] ;; ;; END make commands ;; write/append filename "M107" write/append filename "^/" write/append filename "G91" ; Make coordinates relative write/append filename "^/" write/append filename "G92 E0" ; reset Extruder counter write/append filename "^/" write/append filename "G1 E-2 F900" ;Retract extuder 2mm at 900mm/min write/append filename "^/" write/append filename "G90" ; Use absolute coordinates again write/append filename "^/" ;write/append filename "G1 X5 Y5 F3000.0" ;go to almost home ;write/append filename "^/" write/append filename "M84" ;disable steppers so they dont get hot during idling... write/append filename "^/" write/append filename "M104 S200" write/append filename "^/" ;M140 S0 ; make sure the bed is turned off. ;M84 ; shut down motors. ; filament used = 13.8mm (0.1cm3) ] ;; ;; Controllers UI ;; controllers: layout [ anti-alias on backdrop effect [gradient 1x1 0.0.0 50.50.50] at 20x10 text "SpiralG" white at 20x35 status: info bold "SpiralG v0.1" 220x25 font-color white ;; Live recording buttons at 185x335 button 70 50.50.50 edge [size: 1x1] "Quit" [quit] ;; Prefs buttons at 20x335 button 70 50.50.50 edge [size: 1x1] "Make" [make3d ] ; at 100x335 button 70 50.50.50 edge [size: 1x1] "" [ ] at 5x70 text "Angle de demarrage" snow at 15x90 slider 220x16 [startangle: to-integer (value * 100) status/text: form startangle show status] at 5x110 text "Increment angle" snow at 15x130 slider 220x16 [angleinc: to-integer (value * 100) status/text: form angleinc show status] at 5x150 text "Increment rayon" snow at 15x170 slider 220x16 [rayoninc: value status/text: form rayoninc show status] at 5x190 text "Interations" snow at 15x210 slider 220x16 [maxiterations: to-integer (value * 10000) status/text: form maxiterations show status] ] view/new controllers do-events