Use DepthFirstIterator to get all descendant Nodes

CURA-6915
This commit is contained in:
Nino van Hooff 2020-07-03 14:46:59 +02:00
parent ead0594c56
commit b1cc651a6a

View File

@ -13,6 +13,7 @@ from UM.MimeTypeDatabase import MimeTypeDatabase, MimeType
from UM.PluginRegistry import PluginRegistry # To get the g-code writer. from UM.PluginRegistry import PluginRegistry # To get the g-code writer.
from PyQt5.QtCore import QBuffer from PyQt5.QtCore import QBuffer
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
from cura.CuraApplication import CuraApplication from cura.CuraApplication import CuraApplication
from cura.Snapshot import Snapshot from cura.Snapshot import Snapshot
@ -175,11 +176,7 @@ class UFPWriter(MeshWriter):
Might be empty in case of nonPrintingMesh Might be empty in case of nonPrintingMesh
""" """
nodes = [node]
if node.callDecoration("isGroup"):
nodes = nodes + node.getAllChildren() # all descendants
return [{"name": item.getName()} return [{"name": item.getName()}
for item in nodes for item in DepthFirstIterator(node)
if item.getMeshData() is not None and not item.callDecoration("isNonPrintingMesh") if item.getMeshData() is not None and not item.callDecoration("isNonPrintingMesh")
] ]