mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Retain 3MF mesh positions
Contributes to CURA-5465 Fixed bug by preventing read jobs for 3mf files from being auto-arranged. Boyscout changes: - Fixed typo in `ThreeMFReader.py` (`splitted` → `split`) - Fixed code style in `CuraApplication.py` (`filename` → `file_name`)
This commit is contained in:
parent
62d1cdf0e1
commit
320d73c6e5
2 changed files with 25 additions and 24 deletions
|
@ -1599,10 +1599,12 @@ class CuraApplication(QtApplication):
|
||||||
|
|
||||||
def _readMeshFinished(self, job):
|
def _readMeshFinished(self, job):
|
||||||
nodes = job.getResult()
|
nodes = job.getResult()
|
||||||
filename = job.getFileName()
|
file_name = job.getFileName()
|
||||||
self._currently_loading_files.remove(filename)
|
file_name_lower = file_name.lower()
|
||||||
|
file_extension = file_name_lower.split(".")[-1]
|
||||||
|
self._currently_loading_files.remove(file_name)
|
||||||
|
|
||||||
self.fileLoaded.emit(filename)
|
self.fileLoaded.emit(file_name)
|
||||||
arrange_objects_on_load = not self.getPreferences().getValue("cura/use_multi_build_plate")
|
arrange_objects_on_load = not self.getPreferences().getValue("cura/use_multi_build_plate")
|
||||||
target_build_plate = self.getMultiBuildPlateModel().activeBuildPlate if arrange_objects_on_load else -1
|
target_build_plate = self.getMultiBuildPlateModel().activeBuildPlate if arrange_objects_on_load else -1
|
||||||
|
|
||||||
|
@ -1635,15 +1637,14 @@ class CuraApplication(QtApplication):
|
||||||
node.scale(original_node.getScale())
|
node.scale(original_node.getScale())
|
||||||
|
|
||||||
node.setSelectable(True)
|
node.setSelectable(True)
|
||||||
node.setName(os.path.basename(filename))
|
node.setName(os.path.basename(file_name))
|
||||||
self.getBuildVolume().checkBoundsAndUpdate(node)
|
self.getBuildVolume().checkBoundsAndUpdate(node)
|
||||||
|
|
||||||
is_non_sliceable = False
|
is_non_sliceable = False
|
||||||
filename_lower = filename.lower()
|
|
||||||
for extension in self._non_sliceable_extensions:
|
if file_extension in self._non_sliceable_extensions:
|
||||||
if filename_lower.endswith(extension):
|
is_non_sliceable = True
|
||||||
is_non_sliceable = True
|
|
||||||
break
|
|
||||||
if is_non_sliceable:
|
if is_non_sliceable:
|
||||||
self.callLater(lambda: self.getController().setActiveView("SimulationView"))
|
self.callLater(lambda: self.getController().setActiveView("SimulationView"))
|
||||||
|
|
||||||
|
@ -1662,7 +1663,7 @@ class CuraApplication(QtApplication):
|
||||||
if not child.getDecorator(ConvexHullDecorator):
|
if not child.getDecorator(ConvexHullDecorator):
|
||||||
child.addDecorator(ConvexHullDecorator())
|
child.addDecorator(ConvexHullDecorator())
|
||||||
|
|
||||||
if arrange_objects_on_load:
|
if file_extension != "3mf" and arrange_objects_on_load:
|
||||||
if node.callDecoration("isSliceable"):
|
if node.callDecoration("isSliceable"):
|
||||||
# Only check position if it's not already blatantly obvious that it won't fit.
|
# Only check position if it's not already blatantly obvious that it won't fit.
|
||||||
if node.getBoundingBox() is None or self._volume.getBoundingBox() is None or node.getBoundingBox().width < self._volume.getBoundingBox().width or node.getBoundingBox().depth < self._volume.getBoundingBox().depth:
|
if node.getBoundingBox() is None or self._volume.getBoundingBox() is None or node.getBoundingBox().width < self._volume.getBoundingBox().width or node.getBoundingBox().depth < self._volume.getBoundingBox().depth:
|
||||||
|
@ -1696,7 +1697,7 @@ class CuraApplication(QtApplication):
|
||||||
if select_models_on_load:
|
if select_models_on_load:
|
||||||
Selection.add(node)
|
Selection.add(node)
|
||||||
|
|
||||||
self.fileCompleted.emit(filename)
|
self.fileCompleted.emit(file_name)
|
||||||
|
|
||||||
def addNonSliceableExtension(self, extension):
|
def addNonSliceableExtension(self, extension):
|
||||||
self._non_sliceable_extensions.append(extension)
|
self._non_sliceable_extensions.append(extension)
|
||||||
|
|
|
@ -59,7 +59,7 @@ class ThreeMFReader(MeshReader):
|
||||||
if transformation == "":
|
if transformation == "":
|
||||||
return Matrix()
|
return Matrix()
|
||||||
|
|
||||||
splitted_transformation = transformation.split()
|
split_transformation = transformation.split()
|
||||||
## Transformation is saved as:
|
## Transformation is saved as:
|
||||||
## M00 M01 M02 0.0
|
## M00 M01 M02 0.0
|
||||||
## M10 M11 M12 0.0
|
## M10 M11 M12 0.0
|
||||||
|
@ -68,20 +68,20 @@ class ThreeMFReader(MeshReader):
|
||||||
## We switch the row & cols as that is how everyone else uses matrices!
|
## We switch the row & cols as that is how everyone else uses matrices!
|
||||||
temp_mat = Matrix()
|
temp_mat = Matrix()
|
||||||
# Rotation & Scale
|
# Rotation & Scale
|
||||||
temp_mat._data[0, 0] = splitted_transformation[0]
|
temp_mat._data[0, 0] = split_transformation[0]
|
||||||
temp_mat._data[1, 0] = splitted_transformation[1]
|
temp_mat._data[1, 0] = split_transformation[1]
|
||||||
temp_mat._data[2, 0] = splitted_transformation[2]
|
temp_mat._data[2, 0] = split_transformation[2]
|
||||||
temp_mat._data[0, 1] = splitted_transformation[3]
|
temp_mat._data[0, 1] = split_transformation[3]
|
||||||
temp_mat._data[1, 1] = splitted_transformation[4]
|
temp_mat._data[1, 1] = split_transformation[4]
|
||||||
temp_mat._data[2, 1] = splitted_transformation[5]
|
temp_mat._data[2, 1] = split_transformation[5]
|
||||||
temp_mat._data[0, 2] = splitted_transformation[6]
|
temp_mat._data[0, 2] = split_transformation[6]
|
||||||
temp_mat._data[1, 2] = splitted_transformation[7]
|
temp_mat._data[1, 2] = split_transformation[7]
|
||||||
temp_mat._data[2, 2] = splitted_transformation[8]
|
temp_mat._data[2, 2] = split_transformation[8]
|
||||||
|
|
||||||
# Translation
|
# Translation
|
||||||
temp_mat._data[0, 3] = splitted_transformation[9]
|
temp_mat._data[0, 3] = split_transformation[9]
|
||||||
temp_mat._data[1, 3] = splitted_transformation[10]
|
temp_mat._data[1, 3] = split_transformation[10]
|
||||||
temp_mat._data[2, 3] = splitted_transformation[11]
|
temp_mat._data[2, 3] = split_transformation[11]
|
||||||
|
|
||||||
return temp_mat
|
return temp_mat
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue