After loading a model from a project Y position is ignored

CURA-4269
This commit is contained in:
alekseisasin 2017-09-21 17:36:12 +02:00
parent e73e218c4e
commit 7c462f5703

View file

@ -17,6 +17,7 @@ from cura.Settings.ExtruderManager import ExtruderManager
from cura.QualityManager import QualityManager from cura.QualityManager import QualityManager
from UM.Scene.SceneNode import SceneNode from UM.Scene.SceneNode import SceneNode
from cura.SliceableObjectDecorator import SliceableObjectDecorator from cura.SliceableObjectDecorator import SliceableObjectDecorator
from cura.ZOffsetDecorator import ZOffsetDecorator
MYPY = False MYPY = False
@ -195,7 +196,7 @@ class ThreeMFReader(MeshReader):
translation_matrix.setByTranslation(translation_vector) translation_matrix.setByTranslation(translation_vector)
transformation_matrix.multiply(translation_matrix) transformation_matrix.multiply(translation_matrix)
# Third step: 3MF also defines a unit, wheras Cura always assumes mm. # Third step: 3MF also defines a unit, whereas Cura always assumes mm.
scale_matrix = Matrix() scale_matrix = Matrix()
scale_matrix.setByScaleVector(self._getScaleFromUnit(self._unit)) scale_matrix.setByScaleVector(self._getScaleFromUnit(self._unit))
transformation_matrix.multiply(scale_matrix) transformation_matrix.multiply(scale_matrix)
@ -203,6 +204,11 @@ class ThreeMFReader(MeshReader):
# Pre multiply the transformation with the loaded transformation, so the data is handled correctly. # Pre multiply the transformation with the loaded transformation, so the data is handled correctly.
um_node.setTransformation(um_node.getLocalTransformation().preMultiply(transformation_matrix)) um_node.setTransformation(um_node.getLocalTransformation().preMultiply(transformation_matrix))
# If the object in a saved project is below the bed, keep it that way
if um_node.getMeshData() != None and um_node.getMeshData().getExtents(um_node.getWorldTransformation()).minimum.y < 0:
um_node.addDecorator(ZOffsetDecorator())
um_node.callDecoration("setZOffset",um_node.getMeshData().getExtents(um_node.getWorldTransformation()).minimum.y)
result.append(um_node) result.append(um_node)
except Exception: except Exception: