Commit 27c6745d authored by leonmuller's avatar leonmuller

Patched a bug where script would not output debugging text due to a bug in...

Patched a bug where script would not output debugging text due to a bug in inkscape not finding all the objects in a layer.
parent 81ee497c
...@@ -947,6 +947,7 @@ class Gcode_tools(inkex.Effect): ...@@ -947,6 +947,7 @@ class Gcode_tools(inkex.Effect):
return path return path
#The object isn't a path, and it's not an image. Convert it to an image to be rastered. #The object isn't a path, and it's not an image. Convert it to an image to be rastered.
else : else :
if(node.get("x") > 0):
tmp = self.getTmpPath() #OS tmp directory tmp = self.getTmpPath() #OS tmp directory
bgcol = "#ffffff" #White bgcol = "#ffffff" #White
curfile = curfile = self.args[-1] #The current inkscape project we're exporting from. curfile = curfile = self.args[-1] #The current inkscape project we're exporting from.
...@@ -979,8 +980,10 @@ class Gcode_tools(inkex.Effect): ...@@ -979,8 +980,10 @@ class Gcode_tools(inkex.Effect):
path['data'] = pixels path['data'] = pixels
return path return path
else:
inkex.errormsg("Unable to generate raster for object " + str(node.get("id"))+" as it does not have an x-y coordinate associated.")
inkex.errormsg("skipping node " + str(node.tag)) inkex.errormsg("skipping node " + str(node.get("id")))
self.skipped += 1 self.skipped += 1
return [] return []
...@@ -1034,6 +1037,8 @@ class Gcode_tools(inkex.Effect): ...@@ -1034,6 +1037,8 @@ class Gcode_tools(inkex.Effect):
logger.write("node %s" % str(node.tag)) logger.write("node %s" % str(node.tag))
selected.remove(node) selected.remove(node)
try: try:
newPath = compile_paths(node, trans).copy(); newPath = compile_paths(node, trans).copy();
pathList.append(newPath) pathList.append(newPath)
...@@ -1088,11 +1093,7 @@ class Gcode_tools(inkex.Effect): ...@@ -1088,11 +1093,7 @@ class Gcode_tools(inkex.Effect):
gcode += (";(***** Pulse Rate: %%-%ds *****)\n" % (size-24)) % (altppm) gcode += (";(***** Pulse Rate: %%-%ds *****)\n" % (size-24)) % (altppm)
gcode += ";(%s)\n" % ("*"*size) gcode += ";(%s)\n" % ("*"*size)
gcode += ";(MSG,Starting layer '%s')\n\n" % originalLayerName gcode += ";(MSG,Starting layer '%s')\n\n" % originalLayerName
# 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"
#Fetch the vector or raster data and turn it into GCode #Fetch the vector or raster data and turn it into GCode
for objectData in pathList: for objectData in pathList:
...@@ -1110,6 +1111,8 @@ class Gcode_tools(inkex.Effect): ...@@ -1110,6 +1111,8 @@ class Gcode_tools(inkex.Effect):
elif (curve['type'] == "raster"): elif (curve['type'] == "raster"):
gcode += self.generate_raster_gcode(curve, laserPower, altfeed=altfeed) gcode += self.generate_raster_gcode(curve, laserPower, altfeed=altfeed)
#Turnkey - Need to figure out why inkscape sometimes gets to this point and hasn't found the objects above.
# If there are any objects left over, it's because they don't belong # If there are any objects left over, it's because they don't belong
# to any inkscape layer (bug in inkscape?). Output those now. # to any inkscape layer (bug in inkscape?). Output those now.
if (selected): if (selected):
...@@ -1118,12 +1121,32 @@ class Gcode_tools(inkex.Effect): ...@@ -1118,12 +1121,32 @@ class Gcode_tools(inkex.Effect):
trans = simpletransform.parseTransform("") trans = simpletransform.parseTransform("")
for node in selected: for node in selected:
try: try:
pathList.append(compile_paths(node, trans).copy()) newPath = compile_paths(node, trans).copy();
pathList.append(newPath)
inkex.errormsg("Built gcode for "+str(node.get("id"))+" - will be cut as %s." % (newPath['type']) )
except: except:
messageOnce = True
for objectData in compile_paths(node, trans): for objectData in compile_paths(node, trans):
#if (messageOnce):
inkex.errormsg("Built gcode for group "+str(node.get("id"))+", item %s - will be cut as %s." % (objectData['id'], objectData['type']) )
#messageOnce = False
pathList.append(objectData) pathList.append(objectData)
if (pathList): if (pathList):
#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)) % (originalLayerName)
gcode += (";(***** Laser Power: %%-%ds *****)\n" % (size-25)) % (laserPower)
gcode += (";(***** Feed Rate: %%-%ds *****)\n" % (size-23)) % (altfeed)
if(altppm):
gcode += (";(***** Pulse Rate: %%-%ds *****)\n" % (size-24)) % (altppm)
gcode += ";(%s)\n" % ("*"*size)
gcode += ";(MSG,Starting layer '%s')\n\n" % originalLayerName
for objectData in pathList: for objectData in pathList:
curve = self.parse_curve(objectData) curve = self.parse_curve(objectData)
...@@ -1134,10 +1157,14 @@ class Gcode_tools(inkex.Effect): ...@@ -1134,10 +1157,14 @@ class Gcode_tools(inkex.Effect):
#Fetch the laser power from the export dialog box. #Fetch the laser power from the export dialog box.
laserPower = self.options.laser laserPower = self.options.laser
try:
if (int(layerName) > 0 and int(layerName) <= 100): if (int(layerName) > 0 and int(layerName) <= 100):
laserPower = int(layerName) laserPower = int(layerName)
else : else :
laserPower = self.options.laser laserPower = self.options.laser
except ValueError,e:
laserPower = self.options.laser
inkex.errormsg("Unable to parse power level for layer name. Using default power level %d percent." % (self.options.laser))
#Switch between smoothie power levels and ramps+marlin power levels #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 #ramps and marlin expect 0 to 100 while smoothie wants 0.0 to 1.0
...@@ -1218,7 +1245,9 @@ class Gcode_tools(inkex.Effect): ...@@ -1218,7 +1245,9 @@ class Gcode_tools(inkex.Effect):
gcode += "G28 ; home all\n\n" gcode += "G28 ; home all\n\n"
#if self.options.function == 'Curve': #if self.options.function == 'Curve':
gcode += self.effect_curve(selected) data = self.effect_curve(selected)
if data:
gcode += data
if (self.options.double_sided_cutting): if (self.options.double_sided_cutting):
gcode += "\n\n;(MSG,Please flip over material)\n\n" gcode += "\n\n;(MSG,Please flip over material)\n\n"
...@@ -1246,4 +1275,5 @@ class Gcode_tools(inkex.Effect): ...@@ -1246,4 +1275,5 @@ class Gcode_tools(inkex.Effect):
e = Gcode_tools() e = Gcode_tools()
e.affect() e.affect()
inkex.errormsg("Finished processing.")
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