This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add pen-change pauses w/ layer names

  • Loading branch information...
martymcguire committed Feb 5, 2011
1 parent 553847a commit fd786b1a1ba58636ccbda3570a7e2600dca3dd0f
Showing with 20 additions and 2 deletions.
  1. +3 −0 src/unicorn.inx
  2. +5 −1 src/unicorn.py
  3. +12 −1 src/unicorn/svg_parser.py
View
@@ -40,6 +40,9 @@ Note: Double-check the orientation of your axes when changing these values!</_pa
<param name="num-copies" type="int" min="1" _gui-text="Number of copies">1</param>
<param name="continuous" type="boolean" _gui-text="Plot continuously? (Experimental. Ignores # of copies value above.)">false</param>
</page>
+ <page name="pen_changes" _gui-text="Pen Changes">
+ <param name="pause-on-layer-change" type="boolean" _gui-text="Pause on layer changes?">false</param>
+ </page>
<page name="help" _gui-text="Help">
<_param name="ext_help" type="description" xml:space="preserve">MakerBot Unicorn G-Code Output.
View
@@ -77,6 +77,10 @@ def __init__(self):
action="store", type="string",
dest="continuous", default="false",
help="Plot continuously until stopped.")
+ self.OptionParser.add_option("--pause-on-layer-change",
+ action="store", type="string",
+ dest="pause_on_layer_change", default="false",
+ help="Pause on layer changes.")
self.OptionParser.add_option("--tab",
action="store", type="string",
dest="tab")
@@ -94,7 +98,7 @@ def effect(self):
self.options.num_copies,
self.options.continuous,
self.svg_file)
- parser = SvgParser(self.document.getroot())
+ parser = SvgParser(self.document.getroot(), self.options.pause_on_layer_change)
parser.parse()
for entity in parser.entities:
entity.get_gcode(self.context)
View
@@ -173,6 +173,12 @@ def load(self,node,mat):
inkex.errormsg('Warning: unable to draw text. please convert it to a path first.')
SvgIgnoredEntity.load(self,node,mat)
+class SvgLayerChange():
+ def __init__(self,layer_name):
+ self.layer_name = layer_name
+ def get_gcode(self,context):
+ context.codes.append("M01 (Plotting layer '%s')" % self.layer_name)
+
class SvgParser:
entity_map = {
@@ -191,8 +197,9 @@ class SvgParser:
'text': SvgText
}
- def __init__(self, svg):
+ def __init__(self, svg, pause_on_layer_change='false'):
self.svg = svg
+ self.pause_on_layer_change = pause_on_layer_change
self.entities = []
def getLength( self, name, default ):
@@ -253,6 +260,10 @@ def recursivelyTraverseSvg(self, nodeList,
matNew = composeTransform(matCurrent, parseTransform(node.get("transform")))
if node.tag == inkex.addNS('g','svg') or node.tag == 'g':
+ if (node.get(inkex.addNS('groupmode','inkscape')) == 'layer'):
+ layer_name = node.get(inkex.addNS('label','inkscape'))
+ if(self.pause_on_layer_change == 'true'):
+ self.entities.append(SvgLayerChange(layer_name))
self.recursivelyTraverseSvg(node, matNew, parent_visibility = v)
elif node.tag == inkex.addNS('use','svg') or node.tag == 'use':
refid = node.get(inkex.addNS('href','xlink'))

0 comments on commit fd786b1

Please sign in to comment.