279 |
279 |
280 |
280 |
281 def svg2gcode(self, filename, bed_max_x = 200, bed_max_y = 200, smoothness = 0.2): |
281 def svg2gcode(self, filename, bed_max_x = 200, bed_max_y = 200, smoothness = 0.2): |
282 self.log("Generating paths from SVG...") |
282 self.log("Generating paths from SVG...") |
283 |
283 |
284 preamble = "" |
284 preamble = """ |
|
285 ; Filename: %s |
|
286 ; GCode generated by bitplotter one-night-quick-hack script (marlin code flavour) |
|
287 ; 2015/2016 by NeoSoft - Malte Bayer |
|
288 |
|
289 G21 ; Metric |
|
290 ; We assume Z is in focus height and laser head is focus at bottom left of image! |
|
291 G92 X0 Y0 E0; set zero position - new origin |
|
292 G90 ; absolute positioning |
|
293 M82 ; Set extruder (laser) to absolute positioning |
|
294 M201 X1000 Y1000 E500 ; Set acceleration |
|
295 M203 X1000 Y1000 Z4 E10 ; Set max feedrate |
|
296 M209 S0 ; disable firmware retraction, we dont want to burn holes... |
|
297 M302 ; Allow cold extrudes - doesnt matter because we hack the extruder physically off with the M571 E mod |
|
298 M571 S1 E1 ; Activate Laser output on extrusion, but block real motor movement! |
|
299 G0 X0 Y0 F%d ; Set moving speed TRAVEL_SPEED |
|
300 G1 X0 Y0 F%d ; Set linear engraving speed ENGRAVE_SPEED |
|
301 |
|
302 """ % (filename, TRAVEL_SPEED, ENGRAVE_SPEED) |
|
303 self.log("Travel/Engrave speed: %d mm/sec, %d mm/sec" % ( |
|
304 TRAVEL_SPEED / 60, ENGRAVE_SPEED / 60) ) |
|
305 |
285 postamble = "" |
306 postamble = "" |
286 shape_preamble = "G92 E0\n" |
307 shape_preamble = "G92 E0\n" |
287 shape_postamble = "" |
308 shape_postamble = """M571 S0 E0 |
|
309 M501 ; undo all settings made |
|
310 |
|
311 """ |
|
312 |
288 |
313 |
289 """ |
314 """ |
290 Used to control the smoothness/sharpness of the curves. |
315 Used to control the smoothness/sharpness of the curves. |
291 Smaller the value greater the sharpness. Make sure the |
316 Smaller the value greater the sharpness. Make sure the |
292 value is greater than 0.1 |
317 value is greater than 0.1 |