mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Use the node id as identifier
Now that libSavitar allows us to read the object id from the 3mf file, this id will be propagated as an id inside CuraSceneNodes and it will be used as an identifier to find the object that has to be refreshed. CURA-7333
This commit is contained in:
parent
5bdcc2e5ba
commit
8eb48672e1
2 changed files with 27 additions and 49 deletions
|
@ -52,7 +52,6 @@ class ThreeMFReader(MeshReader):
|
|||
self._root = None
|
||||
self._base_name = ""
|
||||
self._unit = None
|
||||
self._object_count = 0 # Used to name objects as there is no node name yet.
|
||||
|
||||
def _createMatrixFromTransformationString(self, transformation: str) -> Matrix:
|
||||
if transformation == "":
|
||||
|
@ -87,17 +86,20 @@ class ThreeMFReader(MeshReader):
|
|||
## Convenience function that converts a SceneNode object (as obtained from libSavitar) to a scene node.
|
||||
# \returns Scene node.
|
||||
def _convertSavitarNodeToUMNode(self, savitar_node: Savitar.SceneNode, file_name: str = "") -> Optional[SceneNode]:
|
||||
self._object_count += 1
|
||||
|
||||
node_name = savitar_node.getName()
|
||||
node_id = savitar_node.getId()
|
||||
if node_name == "":
|
||||
node_name = "Object %s" % self._object_count
|
||||
if file_name != "":
|
||||
node_name = os.path.basename(file_name)
|
||||
else:
|
||||
node_name = "Object {}".format(node_id)
|
||||
|
||||
active_build_plate = CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate
|
||||
|
||||
um_node = CuraSceneNode() # This adds a SettingOverrideDecorator
|
||||
um_node.addDecorator(BuildPlateDecorator(active_build_plate))
|
||||
um_node.setName(node_name)
|
||||
um_node.setId(node_id)
|
||||
transformation = self._createMatrixFromTransformationString(savitar_node.getTransformation())
|
||||
um_node.setTransformation(transformation)
|
||||
mesh_builder = MeshBuilder()
|
||||
|
@ -169,7 +171,6 @@ class ThreeMFReader(MeshReader):
|
|||
|
||||
def _read(self, file_name: str) -> Union[SceneNode, List[SceneNode]]:
|
||||
result = []
|
||||
self._object_count = 0 # Used to name objects as there is no node name yet.
|
||||
# The base object of 3mf is a zipped archive.
|
||||
try:
|
||||
archive = zipfile.ZipFile(file_name, "r")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue