Initial commit for passing mesh names to CuraEngine

This commit is contained in:
paukstelis 2018-08-19 22:52:17 -04:00
parent 6740c2bee9
commit b66558f97a
3 changed files with 22 additions and 2 deletions

View file

@ -40,6 +40,9 @@ class ObjectsModel(ListModel):
filter_current_build_plate = Application.getInstance().getPreferences().getValue("view/filter_current_build_plate")
active_build_plate_number = self._build_plate_number
group_nr = 1
instance = 1
namecount = []
for node in DepthFirstIterator(Application.getInstance().getController().getScene().getRoot()):
if not isinstance(node, SceneNode):
continue
@ -55,6 +58,7 @@ class ObjectsModel(ListModel):
if not node.callDecoration("isGroup"):
name = node.getName()
else:
name = catalog.i18nc("@label", "Group #{group_nr}").format(group_nr = str(group_nr))
group_nr += 1
@ -63,6 +67,18 @@ class ObjectsModel(ListModel):
is_outside_build_area = node.isOutsideBuildArea()
else:
is_outside_build_area = False
#check if we already have an instance of the object based on name
duplicate = False
for n in namecount:
if name == n["name"]:
name = "{0}({1})".format(name, n["count"])
node.setName(name)
n["count"] = n["count"]+1
duplicate = True
if not duplicate:
namecount.append({"name" : name, "count" : 1})
nodes.append({
"name": name,
@ -71,8 +87,10 @@ class ObjectsModel(ListModel):
"buildPlateNumber": node_build_plate_number,
"node": node
})
nodes = sorted(nodes, key=lambda n: n["name"])
self.setItems(nodes)
print(nodes)
self.itemsChanged.emit()