added maximum group depth to lasercheck
This commit is contained in:
parent
2d3c5e7091
commit
40fd5db819
@ -39,6 +39,7 @@ class LaserCheck(inkex.EffectExtension):
|
|||||||
def effect(self):
|
def effect(self):
|
||||||
|
|
||||||
so = self.options
|
so = self.options
|
||||||
|
selected = [] #total list of elements to parse
|
||||||
|
|
||||||
def parseChildren(element):
|
def parseChildren(element):
|
||||||
if element not in selected:
|
if element not in selected:
|
||||||
@ -51,7 +52,6 @@ class LaserCheck(inkex.EffectExtension):
|
|||||||
parseChildren(child) #go deeper and deeper
|
parseChildren(child) #go deeper and deeper
|
||||||
|
|
||||||
#check if we have selected elements or if we should parse the whole document instead
|
#check if we have selected elements or if we should parse the whole document instead
|
||||||
selected = [] #total list of elements to parse
|
|
||||||
if len(self.svg.selected) == 0:
|
if len(self.svg.selected) == 0:
|
||||||
for element in self.document.getroot().iter(tag=etree.Element):
|
for element in self.document.getroot().iter(tag=etree.Element):
|
||||||
if element != self.document.getroot():
|
if element != self.document.getroot():
|
||||||
@ -60,6 +60,7 @@ class LaserCheck(inkex.EffectExtension):
|
|||||||
else:
|
else:
|
||||||
for element in self.svg.selected.values():
|
for element in self.svg.selected.values():
|
||||||
parseChildren(element)
|
parseChildren(element)
|
||||||
|
|
||||||
namedView = self.document.getroot().find(inkex.addNS('namedview', 'sodipodi'))
|
namedView = self.document.getroot().find(inkex.addNS('namedview', 'sodipodi'))
|
||||||
doc_units = namedView.get(inkex.addNS('document-units', 'inkscape'))
|
doc_units = namedView.get(inkex.addNS('document-units', 'inkscape'))
|
||||||
user_units = namedView.get(inkex.addNS('units'))
|
user_units = namedView.get(inkex.addNS('units'))
|
||||||
@ -165,6 +166,18 @@ class LaserCheck(inkex.EffectExtension):
|
|||||||
|
|
||||||
if so.checks == "check_all" or so.groups_and_layers is True:
|
if so.checks == "check_all" or so.groups_and_layers is True:
|
||||||
inkex.utils.debug("\n---------- Groups and layers")
|
inkex.utils.debug("\n---------- Groups and layers")
|
||||||
|
global md
|
||||||
|
md = 0
|
||||||
|
def maxDepth(element, level):
|
||||||
|
global md
|
||||||
|
if (level == md):
|
||||||
|
md += 1
|
||||||
|
for child in element:
|
||||||
|
maxDepth(child, level + 1)
|
||||||
|
maxDepth(self.document.getroot(), -1)
|
||||||
|
self.msg("Maximum group depth={}".format(md - 1))
|
||||||
|
if md - 1 > 2:
|
||||||
|
self.msg("Warning: this group depth might cause issues!")
|
||||||
groups = []
|
groups = []
|
||||||
layers = []
|
layers = []
|
||||||
for element in selected:
|
for element in selected:
|
||||||
|
Reference in New Issue
Block a user