mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-08 23:46:22 -06:00
Initial commit for passing mesh names to CuraEngine
This commit is contained in:
parent
6740c2bee9
commit
b66558f97a
3 changed files with 22 additions and 2 deletions
|
@ -40,6 +40,9 @@ class ObjectsModel(ListModel):
|
||||||
filter_current_build_plate = Application.getInstance().getPreferences().getValue("view/filter_current_build_plate")
|
filter_current_build_plate = Application.getInstance().getPreferences().getValue("view/filter_current_build_plate")
|
||||||
active_build_plate_number = self._build_plate_number
|
active_build_plate_number = self._build_plate_number
|
||||||
group_nr = 1
|
group_nr = 1
|
||||||
|
instance = 1
|
||||||
|
namecount = []
|
||||||
|
|
||||||
for node in DepthFirstIterator(Application.getInstance().getController().getScene().getRoot()):
|
for node in DepthFirstIterator(Application.getInstance().getController().getScene().getRoot()):
|
||||||
if not isinstance(node, SceneNode):
|
if not isinstance(node, SceneNode):
|
||||||
continue
|
continue
|
||||||
|
@ -55,6 +58,7 @@ class ObjectsModel(ListModel):
|
||||||
|
|
||||||
if not node.callDecoration("isGroup"):
|
if not node.callDecoration("isGroup"):
|
||||||
name = node.getName()
|
name = node.getName()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
name = catalog.i18nc("@label", "Group #{group_nr}").format(group_nr = str(group_nr))
|
name = catalog.i18nc("@label", "Group #{group_nr}").format(group_nr = str(group_nr))
|
||||||
group_nr += 1
|
group_nr += 1
|
||||||
|
@ -63,6 +67,18 @@ class ObjectsModel(ListModel):
|
||||||
is_outside_build_area = node.isOutsideBuildArea()
|
is_outside_build_area = node.isOutsideBuildArea()
|
||||||
else:
|
else:
|
||||||
is_outside_build_area = False
|
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({
|
nodes.append({
|
||||||
"name": name,
|
"name": name,
|
||||||
|
@ -71,8 +87,10 @@ class ObjectsModel(ListModel):
|
||||||
"buildPlateNumber": node_build_plate_number,
|
"buildPlateNumber": node_build_plate_number,
|
||||||
"node": node
|
"node": node
|
||||||
})
|
})
|
||||||
|
|
||||||
nodes = sorted(nodes, key=lambda n: n["name"])
|
nodes = sorted(nodes, key=lambda n: n["name"])
|
||||||
self.setItems(nodes)
|
self.setItems(nodes)
|
||||||
|
print(nodes)
|
||||||
|
|
||||||
self.itemsChanged.emit()
|
self.itemsChanged.emit()
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,8 @@ message Object
|
||||||
bytes normals = 3; //An array of 3 floats.
|
bytes normals = 3; //An array of 3 floats.
|
||||||
bytes indices = 4; //An array of ints.
|
bytes indices = 4; //An array of ints.
|
||||||
repeated Setting settings = 5; // Setting override per object, overruling the global settings.
|
repeated Setting settings = 5; // Setting override per object, overruling the global settings.
|
||||||
|
//PJP
|
||||||
|
string name = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Progress
|
message Progress
|
||||||
|
|
|
@ -256,7 +256,7 @@ class StartSliceJob(Job):
|
||||||
mesh_data = object.getMeshData()
|
mesh_data = object.getMeshData()
|
||||||
rot_scale = object.getWorldTransformation().getTransposed().getData()[0:3, 0:3]
|
rot_scale = object.getWorldTransformation().getTransposed().getData()[0:3, 0:3]
|
||||||
translate = object.getWorldTransformation().getData()[:3, 3]
|
translate = object.getWorldTransformation().getData()[:3, 3]
|
||||||
|
|
||||||
# This effectively performs a limited form of MeshData.getTransformed that ignores normals.
|
# This effectively performs a limited form of MeshData.getTransformed that ignores normals.
|
||||||
verts = mesh_data.getVertices()
|
verts = mesh_data.getVertices()
|
||||||
verts = verts.dot(rot_scale)
|
verts = verts.dot(rot_scale)
|
||||||
|
@ -268,7 +268,7 @@ class StartSliceJob(Job):
|
||||||
|
|
||||||
obj = group_message.addRepeatedMessage("objects")
|
obj = group_message.addRepeatedMessage("objects")
|
||||||
obj.id = id(object)
|
obj.id = id(object)
|
||||||
|
obj.name = object.getName()
|
||||||
indices = mesh_data.getIndices()
|
indices = mesh_data.getIndices()
|
||||||
if indices is not None:
|
if indices is not None:
|
||||||
flat_verts = numpy.take(verts, indices.flatten(), axis=0)
|
flat_verts = numpy.take(verts, indices.flatten(), axis=0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue