Commit 23360535 authored by leonmuller's avatar leonmuller

07-March-2015 - 10 hours : Cleaned up the exporters code a lot. Added ppm and...

07-March-2015 - 10 hours : Cleaned up the exporters code a lot. Added ppm and feedrate detection from
the layer name. Updated the gcode that is exported to be neater and work better with
pulsed mode using G01, G02 and G03 commands.

07-March-2015 - Fixed the G28 command at the end of the job. Added defaults for laser power,
feedrates and ppm if defined. If ppm isn't defined in the layer options it will operate as
continuous wave mode. See the help in the extension dialog for how to use.

07-March-2015 - Marlin codebase mod : You need to patch the Marlin codebase to turn on the
laser before moving for G02 and G03 commands. This plugin assumes this has been done. More
details to come in the future. Copy the code from the G01 above in marlin_main.cpp
parent 5399d4b5
About This Fork
---------------
10.14.14 by ajf (https://github.com/ajfoul)
About This Project
------------------
Modified to output gcode that is compatible with K40 style laser cutter
running Marlin
(https://github.com/lansing-makers-network/buildlog-lasercutter-marlin).
I couldn't get the original version from LMN repo to work with LMN's Marlin as
it never set the laser intensity on the M3 command.
This works form me, but YMMV. Very limited testing. Never leave your laser
cutter unattended while it's powered/operating. Keep a fire extinguisher
close by, wear saftey goggles, and be afraid!
USE AT YOUR OWN RISK!
10.17.14 - A little more testing reveals that G02 (CW ARC) and G03 (CCW ARC)
moves are problematic. Not sure if it's the modifications in this fork, the
original THLaser, LMN's Marlin, Inkscape, or some combination that is causing
the issues.
running Marlin (https://github.com/lansing-makers-network/buildlog-lasercutter-marlin).
Basically, you should consider this pre-alpha code. Examine the exported
Gcode and do test runs on cardboard/paper before trying to cut on valuable
stock.
26-Feb-2015 - 2 hours : Forked from user ajfoul to extend functionality of smoothie
laser power levels 0.0 to 1.0, generic Marlin power levels being 0 to 100.
Also: G28 at the end of the job doesn't seem to be working at the moment, at
least not when running the gcode on my machine.
07-March-2015 - 10 hours : Cleaned up the exporters code a lot. Added ppm and feedrate detection from
the layer name. Updated the gcode that is exported to be neater and work better with
pulsed mode using G01, G02 and G03 commands.
10.19.14 - G02 and G03 really screw things up, so I've set the default
min_arc_radius to 500 to force all cut moves to be G01. That has it's own
issues. At this point I wouldn't recommend using the Gcode from this for any
real jobs.
07-March-2015 - Fixed the G28 command at the end of the job. Added defaults for laser power,
feedrates and ppm if defined. If ppm isn't defined in the layer options it will operate as
continuous wave mode. See the help in the extension dialog for how to use.
26-Feb-2015 - Forked from user ajfoul to extend functionality of smoothie
laser power levels 0.0 to 1.0, generic Marlin power levels being 0 to 100 and to add in
raster image detection and export support.
07-March-2015 - Marlin codebase mod : You need to patch the Marlin codebase to turn on the
laser before moving for G02 and G03 commands. This plugin assumes this has been done. More
details to come in the future. Copy the code from the G01 above in marlin_main.cpp
THLaser Inkscape Plugin
-----------------------
Turnkey Laser Inkscape Gcode Export Plugin
------------------------------------------
This program is an Inkscape extension for exporting a set of paths as
gcode script.
......@@ -49,7 +31,7 @@ is released under the same license (GPL v2).
Installation
------------
Copy the files thlaser.py and thlaser.inx into your Inkscape extensions
Copy the files turnkeylaser.py and turnkeylaser.inx into your Inkscape extensions
folder. Fire up inkscape and you will find the plugin under Extensions ->
Export -> THLaser GCode Export.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Note : 73% on my unit runs the laser tube at 18ma. This is the maximum current that should be put through a 40 watt CO2 laser tube.
Cut Perspex = F300 @ 73%
Score cardboard = F1400 @ 9%
Cut Paper (Pulsed) = F600 @ 8% - 60ms pulse 2 pulse per millimetre.
\ No newline at end of file
G21 ; All units in mm
; Default Cut Feedrate 300 mm per minute
; Default Move Feedrate 2000 mm per minute
; Default Laser Intensity 72 percent
G28 ; home all
M5 ;turn the laser off
;(************************************************************)
;(***** Layer: 8 *****)
;(***** Laser Power: 8 *****)
;(***** Feed Rate: 600.0 *****)
;(***** Pulse Rate: None *****)
;(************************************************************)
;(MSG,Starting layer '8')
G00 X93.693928 Y42.800959 F2000
G01 S8.00 X93.693928 Y123.034303 F600 B0 D0
M5 ;turn the laser off
M5 ;turn the laser off
;(************************************************************)
;(***** Layer: 8 *****)
;(***** Laser Power: 8 *****)
;(***** Feed Rate: 600.0 *****)
;(***** Pulse Rate: 2.0 *****)
;(************************************************************)
;(MSG,Starting layer '8')
G00 X89.182149 Y42.856593 F2000
G01 S8.00 X89.182149 Y123.089937 F600 L60000 P1 B1 D0
M5 ;turn the laser off
M5 ;turn the laser off
;(************************************************************)
;(***** Layer: 8 *****)
;(***** Laser Power: 8 *****)
;(***** Feed Rate: 600.0 *****)
;(***** Pulse Rate: 1.0 *****)
;(************************************************************)
;(MSG,Starting layer '8')
G00 X84.297648 Y42.816729 F2000
G01 S8.00 X84.297648 Y123.050073 F600 L60000 P0.5 B1 D0
M5 ;turn the laser off
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension>
<name>ShinyLaser Gcode</name>
<id>com.istartup.shinylaser</id>
<name>TurnkeyLaser Exporter</name>
<id>com.turnkey.Tyranny</id>
<effect>
<object-type>path</object-type>
......@@ -10,16 +10,30 @@
</effects-menu>
</effect>
<dependency type="executable" location="extensions">shinylaser.py</dependency>
<dependency type="executable" location="extensions">turnkeylaser.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<script>
<command reldir="extensions" interpreter="python">shinylaser.py</command>
<command reldir="extensions" interpreter="python">turnkeylaser.py</command>
</script>
<param name='tab' type="notebook">
<page name='tab' _gui-text='Help'>
<_param name="fullhelp" type="description">ShinyLaser exports Inkscape paths to Gcode compatible with Ramps+Marlin or Smoothieware laser mainboards.
<_param name="fullhelp" type="description">TurnkeyLaser exports Inkscape paths to Gcode compatible with Ramps+Marlin or Smoothieware laser mainboards.
You're able to specify in your layer names the laser power output, feedrate and optionally the pulse per millimetre option for pulsed lasing mode as opposed to the default continuous wave operation mode.
1)Name your layer like the following example :
35 [feed=600,ppm=40]
2)Draw your designs and group them based on lasing options in the layer name.
3)Select the paths you want to export, then run this script.
In the example above the layer will be cut at 35% power with a feedrate of 600mm per minute and a pulse rate of 40 pulses per millimetre (at 60ms pulses).
If the ppm option isn't specified in the layer options then output lines will be cut in continuous wave mode at the power and feed specified.
If you do not specify the laser power or other options in the layer name then they will default to the options in the export dialog box under "Preferences".
For the latest revision please visit https://github.com/TurnkeyTyranny/laser-gcode-exporter-inkscape-plugin
</_param>
</page>
......@@ -28,10 +42,10 @@
<item value="ramps">Ramps 1.4</item>
<item value="smoothie">Smoothie</item>
</param>
<param name="biarc-tolerance" type='float' _gui-text='Biarc interpolation tolerance'>1</param>
<param name="biarc-tolerance" type='float' _gui-text='Biarc interpolation tolerance'>0.5</param>
<_param name="help" type="description">Biarc interpolation tolerance is the maximum allowed distance between a path and it's approximation. If this value is exceeded, the path will be split into two segments.</_param>
<param name="biarc-max-split-depth" type="int" _gui-text="Maximum splitting depth">4</param>
<param name="min-arc-radius" type="float" precision="5" min="-1000" max="1000" _gui-text="Minimum arc radius">0.05</param>
<param name="min-arc-radius" type="float" precision="5" min="-1000" max="5000" _gui-text="Minimum arc radius">0.00005</param>
<param name="Xoffset" type="float" precision="4" min="-1000" max="1000" _gui-text="Offset along X axis">0.0</param>
<param name="Yoffset" type="float" precision="4" min="-1000" max="1000" _gui-text="Offset along Y axis">0.0</param>
<param name="logging" type="boolean" _gui-text="Log debug output from plugin:">true</param>
......@@ -41,16 +55,16 @@
<param name="filename" type="string" _gui-text="File name: ">output.g</param>
<param name="directory" type="string" _gui-text="Directory: "></param>
<_param name="help" type="description">(blank is your desktop)</_param>
<param name="feed" type="int" min="0" max="5000" _gui-text="Cut Feedrate:">5000</param>
<param name="Mfeed" type="int" min="0" max="5000" _gui-text="Traversal Feedrate:">1400</param>
<param name="laser" type="int" min="0" max="100" _gui-text="Laser Intensity (0-100%):">10</param>
<param name="feed" type="int" min="0" max="5000" _gui-text="Default Cut Feedrate:">300</param>
<param name="Mfeed" type="int" min="0" max="5000" _gui-text="Default Traversal Feedrate:">2000</param>
<param name="laser" type="int" min="0" max="100" _gui-text="Default Laser Intensity (0-100%):">10</param>
<param name="homebefore" type="boolean" _gui-text="Home X & Y Before:">true</param>
<param name="homeafter" type="boolean" _gui-text="Home X & Y After:">false</param>
<param name="Xscale" type="float" precision="4" min="-1000" max="1000" _gui-text="Scale along X axis:">1</param>
<param name="Yscale" type="float" precision="4" min="-1000" max="1000" _gui-text="Scale along Y axis:">1</param>
<param name="double_sided_cutting" type="boolean" _gui-text="Double-sided cutting:">false</param>
<param name="draw-curves" type="boolean" _gui-text="Draw curves:">true</param>
<param name="double_sided_cutting" type="boolean" _gui-text="Cut both sides of material?">false</param>
<param name="draw-curves" type="boolean" _gui-text="Draw curves in inkscape layer">true</param>
<param name="unit" type="enum" _gui-text="Units: ">
<item value="mm">mm</item>
......
#!/usr/bin/env python
"""
ShinyLaser
TurnkeyLaserExporter
"""
"""
think|haus gcode inkscape extension
-----------------------------------
Maintained by Peter Rogers (peter.rogers@gmail.com)
Customized to suit our needs at thinkhaus.org (see change log below)
Maintained by Turnkey Tyranny (https://github.com/TurnkeyTyranny/laser-gcode-exporter-inkscape-plugin)
Designed to run on Ramps 1.4 + Marlin firmware on a K40 CO2 Laser Cutter.
Based on think|haus gcode inkscape extension
Based on a script by Nick Drobchenko from the CNC club
***
......@@ -36,45 +33,22 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""
"""
Changelog 2012-01-12 - PAR:
* fixed bug in compile_paths when dealing with empty node data
Changelog 2011-10-16 - PAR:
* general code cleanup to make things more readable
* now inkscape coordinate system matches laser bed coordinate system
* removed "area curve" code, since it wasn't being used and wasn't working anyways
* cleanup of source code, reorganized the dialog window
Changelog 2011-08-06 - PAR:
* layer and group transforms now taken into account
* tool change now happens on every layer (only when multiple layers present)
* displays a message at the start of each layer
Changelog 2011-07-31 - PAR:
* misc bug fixes
* objects in document root (ie not in a layer) now outputted properly
* skips 'comment' layers (ie name prefixed with '#')
* warns about any selected objects not outputted by the script
Changelog 2011-07-01 - PAR:
* logging is now enabled by default
* handling groups and layers properly
* toolchange operation (M6) added between outputting layers
* removed 'options.ids' in favor of 'self.selected'
Changelog 2011-02-20 - Adina:
* removed any movement in the z axis when the laser is trying to etch a curve.
* removed extra M3s: the laser only turns on at the beginning of a cut block, not before every line.
Changelog 2010-04-07 - Adina:
* separate scaling factor for x and y,
* x and y scaled to mm or inches that match the dimensions in inkscape (not 1px = 1 in or mm)
Changelog 2010-04-20:
* made the .inx file refer to the correct .py file... it should work now?
Notes : M649 S100 L300 P10 - Laser 100 percent, pulses are each 300ms, and 10 pulses per mm.
Changelog 2015-02-01:
* Beginning of the project. Based on a fork from ShinyLaser(https://github.com/ajfoul/thlaser-inkscape-plugin)
Changelog 2015-02-16:
Added an option to export as Marlin or Smoothie Power levels
Changelog 2015-03-07:
Added capability to pick out power, ppm, feedrate etc from the layer names
Added code to support Pulse Per Minute burning or continuous burning. Will default to continuous.
M649 S100 L300 P10 - Set Laser settings to 100 percent power, pulses are each 300ms, and 10 pulses per mm.
G0 : Move to a new location with the laser off.
G1 : Move to a new location with the laser on.
G2 : Move in a Clockwise Arc
G3 : Move in a Counter Clockwise Arc
Name your layer like 10 [feed=600,ppm=40] for 10% power, 600mm per minute cut and 40 pulse per millimetre at 60ms duration
"""
###
......@@ -91,7 +65,7 @@ import re
import copy
import sys
import time
_ = inkex._
#_ = inkex._
################################################################################
......@@ -104,9 +78,8 @@ VERSION = "1.0.1"
STRAIGHT_TOLERANCE = 0.0001
STRAIGHT_DISTANCE_TOLERANCE = 0.0001
LASER_ON = "M3" # Peter - LASER ON MCODE
LASER_OFF = "M5\n" # Peter - LASER OFF MCODE
TOOL_CHANGE = "T%02d (select tool)\nM6 (tool change)\n\n"
LASER_ON = "M3 ;turn the laser on" # LASER ON MCODE
LASER_OFF = "M5 ;turn the laser off\n" # LASER OFF MCODE
HEADER_TEXT = ""
FOOTER_TEXT = ""
......@@ -436,9 +409,10 @@ class Gcode_tools(inkex.Effect):
self.OptionParser.add_option("-x", "--Xoffset", action="store", type="float", dest="Xoffset", default="0.0", help="Offset along X")
self.OptionParser.add_option("-y", "--Yoffset", action="store", type="float", dest="Yoffset", default="0.0", help="Offset along Y")
# added move (laser off) feedrate and laser intensity; made all int rather than float - (ajf)
self.OptionParser.add_option("-p", "--feed", action="store", type="int", dest="feed", default="60", help="Cut Feed rate in unit/min")
self.OptionParser.add_option("-m", "--Mfeed", action="store", type="int", dest="Mfeed", default="300", help="Move Feed rate in unit/min")
self.OptionParser.add_option("-l", "--laser", action="store", type="int", dest="laser", default="10", help="Laser intensity (0-100 %)")
self.OptionParser.add_option("-m", "--Mfeed", action="store", type="int", dest="Mfeed", default="2000", help="Default Move Feed rate in unit/min")
self.OptionParser.add_option("-p", "--feed", action="store", type="int", dest="feed", default="300", help="Default Cut Feed rate in unit/min")
self.OptionParser.add_option("-l", "--laser", action="store", type="int", dest="laser", default="10", help="Default Laser intensity (0-100 %)")
self.OptionParser.add_option("-b", "--homebefore", action="store", type="inkbool", dest="homebefore", default=True, help="Home all beofre starting (G28)")
self.OptionParser.add_option("-a", "--homeafter", action="store", type="inkbool", dest="homeafter", default=False, help="Home X Y at end of job")
......@@ -458,7 +432,9 @@ class Gcode_tools(inkex.Effect):
self.OptionParser.add_option("", "--loft-direction", action="store", type="string", dest="loft_direction", default="crosswise", help="Direction of loft's interpolation.")
self.OptionParser.add_option("", "--loft-interpolation-degree",action="store", type="float", dest="loft_interpolation_degree", default="2", help="Which interpolation use to loft the paths smooth interpolation or staright.")
self.OptionParser.add_option("", "--min-arc-radius", action="store", type="float", dest="min_arc_radius", default="500.0", help="All arc having radius less than minimum will be considered as straight line")
self.OptionParser.add_option("", "--min-arc-radius", action="store", type="float", dest="min_arc_radius", default="0.0005", help="All arc having radius less than minimum will be considered as straight line")
self.OptionParser.add_option("", "--mainboard", action="store", type="string", dest="mainboard", default="ramps", help="Mainboard")
def parse_curve(self, path):
# if self.options.Xscale!=self.options.Yscale:
......@@ -591,53 +567,68 @@ class Gcode_tools(inkex.Effect):
args.append(s[i] + ("%f" % value) + s1[i])
return " ".join(args)
def generate_gcode(self, curve, depth, altfeed=None):
def generate_gcode(self, curve, depth, laserPower, altfeed=None, altppm=None):
gcode = ''
#Setup our feed rate, either from the layer name or from the default value.
if (altfeed):
# Use the "alternative" feed rate specified
f = " F%i" % altfeed
cutFeed = "F%i" % altfeed
else:
if self.options.generate_not_parametric_code:
f = " F%i" % self.options.feed
cutFeed = "F%i" % self.options.feed
else:
cutFeed = "F%i" % self.options.feed
#Setup our pulse per millimetre option, if applicable
#B: laser firing mode (0 = continuous, 1 = pulsed, 2 = raster)
if (altppm):
# Use the "alternative" ppm - L60000 is 60ms
ppmValue = "L60000 P%.2f B1 D0" % altppm
else:
f = " F100"
#Set the laser firing mode to continuous.
ppmValue = "B0 D0"
cwArc = "G02"
ccwArc = "G03"
if (self.flipArcs):
# The geometry is reflected, so invert the orientation of the arcs to match
if (self.flipArcs):
(cwArc, ccwArc) = (ccwArc, cwArc)
# Peter's note: Here's where the 'laser on' and 'laser off' m-codes get appended to the GCODE generation
# The 'laser on' and 'laser off' m-codes get appended to the GCODE generation
lg = 'G00'
for i in range(1,len(curve)):
s, si = curve[i-1], curve[i]
#feed = f if lg not in ['G01','G02','G03'] else ''
if (lg not in ["G01", "G02", "G03"]):
feed = f
else:
feed = ""
#G00 : Move with the laser off to a new point
if s[1] == 'move':
# Traversals (G00) tend to signal either the toolhead coming up, going down, or indexing to a new workplace. All other cases seem to signal cutting.
gcode += LASER_OFF + "\nG00" + " " + self.make_args(si[0]) + " F%i" % self.options.Mfeed + "\n"
#Turn off the laser if it was on previously.
if lg != "G00":
gcode += LASER_OFF + "\n"
gcode += "G00" + " " + self.make_args(si[0]) + " F%i" % self.options.Mfeed + "\n"
lg = 'G00'
elif s[1] == 'end':
lg = 'G00'
#G01 : Move with the laser turned on to a new point
elif s[1] == 'line':
if lg=="G00":
#gcode += "G01 " + self.make_args([None,None,s[5][0]+depth]) + feed +"\n" + LASER_ON
gcode += LASER_ON + "\n"
gcode += "G01 " + "S%.2f " % self.options.laser + self.make_args(si[0]) + " F%i" % self.options.feed + "\n"
#No longer needed because G01, G02 and G03 will be forced in marlin to automatically fire the laser.
#If the laser was turned off, turn it back on.
#if lg == "G00":
# gcode += LASER_ON + "\n"
gcode += "G01 " + "S%.2f " % laserPower + self.make_args(si[0]) + " %s " % cutFeed + "%s" % ppmValue + "\n"
lg = 'G01'
#G02 and G03 : Move in an arc with the laser turned on.
elif s[1] == 'arc':
if lg=="G00":
#gcode += "G01 " + self.make_args([None,None,s[5][0]+depth]) + feed +"\n" + LASER_ON
gcode += LASER_ON + "\n"
#No longer needed because G01, G02 and G03 will be forced in marlin to automatically fire the laser.
#If the laser was turned off, turn it back on.
#if lg == "G00":
# gcode += LASER_ON + "\n"
dx = s[2][0]-s[0][0]
dy = s[2][1]-s[0][1]
......@@ -649,7 +640,7 @@ class Gcode_tools(inkex.Effect):
gcode += cwArc
else:
gcode += ccwArc
gcode += " " + "S%.2f " % self.options.laser + self.make_args(si[0] + [None, dx, dy, None]) + " F%i" % self.options.feed + "\n"
gcode += " " + "S%.2f " % laserPower + self.make_args(si[0] + [None, dx, dy, None]) + " %s " % cutFeed + "%s" % ppmValue + "\n"
else:
r = (r1.mag()+r2.mag())/2
......@@ -657,21 +648,19 @@ class Gcode_tools(inkex.Effect):
gcode += cwArc
else:
gcode += ccwArc
gcode += " " + "S%.2f " % self.options.laser + self.make_args(si[0]) + " R%f" % (r*self.options.Xscale) + " F%i" % self.options.feed + "\n"
gcode += " " + "S%.2f " % laserPower + self.make_args(si[0]) + " R%f" % (r*self.options.Xscale) + " %s " % cutFeed + "%s" % ppmValue + "\n"
lg = cwArc
#The arc is less than the minimum arc radius, draw it as a straight line.
else:
if lg=="G00":
#gcode += "G01 " + self.make_args([None,None,s[5][0]+depth]) + feed +"\n" + LASER_ON
gcode += LASER_ON + "\n"
gcode += "G01 " + "S%.2f " % self.options.laser + self.make_args(si[0]) + " F%i" % self.options.feed + "\n"
gcode += "G01 " + "S%.2f " % laserPower + self.make_args(si[0]) + " %s " % cutFeed + "%s" % ppmValue + "\n"
lg = 'G01'
#The end of the layer.
if si[1] == 'end':
gcode += LASER_OFF
if self.options.homeafter:
gcode += "\n\nG00 X0 Y0 F4000 ; home"
return gcode
......@@ -735,12 +724,6 @@ class Gcode_tools(inkex.Effect):
layers = list(reversed(get_layers(self.document)))
#Switch between smoothie power levels and ramps+marlin power levels
#ramps and marlin expect 0 to 100 while smoothie wants 0.0 to 1.0
if (self.options.mainboard == 'smoothie'):
self.options.laser = self.options.laser / 100
# Loop over the layers and objects
gcode = ""
for layer in layers:
......@@ -762,6 +745,7 @@ class Gcode_tools(inkex.Effect):
# Check if the layer specifies an alternative (from the default) feed rate
altfeed = layerParams.get("feed", None)
altppm = layerParams.get("ppm", None)
logger.write("layer %s" % layerName)
if (layerParams):
......@@ -784,25 +768,46 @@ class Gcode_tools(inkex.Effect):
continue
curve = self.parse_curve(pathList)
#Determind the power of the laser that this layer should be cut at.
#If the layer is not named as an integer value then default to the laser intensity set at the export settings.
#Fetch the laser power from the export dialog box.
laserPower = self.options.laser
if (int(layerName) > 0 and int(layerName) <= 100):
laserPower = int(layerName)
else :
laserPower = self.options.laser
#Switch between smoothie power levels and ramps+marlin power levels
#ramps and marlin expect 0 to 100 while smoothie wants 0.0 to 1.0
if (self.options.mainboard == 'smoothie'):
laserPower = laserPower / 100
# If there are several layers, start with a tool change operation
if (len(layers) > 1):
#Turnkey : Always output the layer header for information.
if (len(layers) > 0):
gcode += LASER_OFF+"\n"
size = 60
gcode += ";(%s)\n" % ("*"*size)
gcode += (";(***** LAYER: %%-%ds *****)\n" % (size-19)) % (layerName)
gcode += (";(***** Layer: %%-%ds *****)\n" % (size-19)) % (layerName)
gcode += (";(***** Laser Power: %%-%ds *****)\n" % (size-25)) % (laserPower)
gcode += (";(***** Feed Rate: %%-%ds *****)\n" % (size-23)) % (altfeed)
gcode += (";(***** Pulse Rate: %%-%ds *****)\n" % (size-24)) % (altppm)
gcode += ";(%s)\n" % ("*"*size)
gcode += ";(MSG,Starting layer '%s')\n\n" % layerName
# Move the laser into the starting position (so that way it is positioned
# for testing the power level, if the user wants to change that).
arg = curve[0]
pt = arg[0]
gcode += "G00 " + self.make_args(pt) + "\n"
gcode += self.tool_change()
#gcode += "G00 " + self.make_args(pt) + "\n"
if (self.options.drawCurves):
self.draw_curve(curve)
gcode += self.generate_gcode(curve, 0, altfeed=altfeed)
#Generate the GCode for this layer
gcode += self.generate_gcode(curve, 0, laserPower, altfeed=altfeed, altppm=altppm)
# If there are any objects left over, it's because they don't belong
# to any inkscape layer (bug in inkscape?). Output those now.
......@@ -818,13 +823,21 @@ class Gcode_tools(inkex.Effect):
if (self.options.drawCurves):
self.draw_curve(curve)
gcode += "\n(*** Root objects ***)\n"
if (layers):
# Include a tool change operation between the layers outputted above
# and these "orphaned" objects.
gcode += self.tool_change()
gcode += "\n;(*** Root objects ***)\n"
#Fetch the laser power from the export dialog box.
laserPower = self.options.laser
#Switch between smoothie power levels and ramps+marlin power levels
#ramps and marlin expect 0 to 100 while smoothie wants 0.0 to 1.0
if (self.options.mainboard == 'smoothie'):
laserPower = laserPower / 100
gcode += self.generate_gcode(curve, 0, laserPower)
if self.options.homeafter:
gcode += "\n\nG00 X0 Y0 F4000 ; home"
gcode += self.generate_gcode(curve, 0)
return gcode
def effect(self):
......@@ -870,9 +883,9 @@ class Gcode_tools(inkex.Effect):
if not self.options.generate_not_parametric_code:
gcode += """
; Cut Feedrate %i
; Move Feedrate %i
; Laser Intensity %i \n""" % (self.options.feed, self.options.Mfeed, self.options.laser)
; Default Cut Feedrate %i mm per minute
; Default Move Feedrate %i mm per minute
; Default Laser Intensity %i percent\n""" % (self.options.feed, self.options.Mfeed, self.options.laser)
if self.options.homebefore:
gcode += "G28 ; home all\n\n"
......
G21 ; All units in mm
; Cut Feedrate 400
; Traversal Feedrate 4000
G0 X0 Y0 ; home
M5
G00 X2.762953 Y240.677863 F4000
M3
G01 S0.1 X132.762873 Y240.677863 F400
G01 S0.1 X132.762873 Y1.678163 F400
G01 S0.1 X2.762953 Y1.678163 F400
G01 S0.1 X2.762953 Y240.677863 F400
G01 S0.1 X2.762953 Y240.677863 F400
M5
G00 X67.763619 Y71.178072 F4000
M3
G02 S0.1 X32.407879 Y85.822898 I0.000000 J50.000566 F400
G02 S0.1 X17.763053 Y121.178638 I35.355739 J35.355739 F400
G02 S0.1 X32.407510 Y156.533259 I49.998760 J0.000000 F400
G02 S0.1 X67.763619 Y171.178146 I35.356109 J-35.356428 F400
G02 S0.1 X103.118876 Y156.533113 I-0.000000 J-49.998906 F400
G02 S0.1 X117.762774 Y121.178638 I-35.355859 J-35.354475 F400
G02 S0.1 X103.118507 Y85.823044 I-50.001564 J-0.000000 F400
G02 S0.1 X67.763619 Y71.178072 I-35.354888 J35.353184 F400
G01 S0.1 X67.763619 Y71.178072 F400
M5
G0 X0 Y0 ; home
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment