Model translations while changing build plates

while importing models, coordinate translations shouldn’t matter and the object should be organized on the plate where it finds space.

CURA-11166
This commit is contained in:
saumya.jain 2023-12-04 17:07:43 +01:00
parent 58c174ff68
commit ce0cdd0b91

View file

@ -179,6 +179,7 @@ class CuraApplication(QtApplication):
self._use_single_instance = False
self._single_instance = None
self._project_mode = None
self._cura_formula_functions = None # type: Optional[CuraFormulaFunctions]
@ -1845,7 +1846,7 @@ class CuraApplication(QtApplication):
Logger.log("i", "Attempting to read file %s", file.toString())
if not file.isValid():
return
self._project_mode = project_mode
scene = self.getController().getScene()
for node in DepthFirstIterator(scene.getRoot()):
@ -1855,16 +1856,16 @@ class CuraApplication(QtApplication):
is_project_file = self.checkIsValidProjectFile(file)
if project_mode is None:
project_mode = self.getPreferences().getValue("cura/choice_on_open_project")
if self._project_mode is None:
self._project_mode = self.getPreferences().getValue("cura/choice_on_open_project")
if is_project_file and project_mode == "open_as_project":
if is_project_file and self._project_mode == "open_as_project":
# open as project immediately without presenting a dialog
workspace_handler = self.getWorkspaceFileHandler()
workspace_handler.readLocalFile(file, add_to_recent_files_hint = add_to_recent_files)
return
if is_project_file and project_mode == "always_ask":
if is_project_file and self._project_mode == "always_ask":
# present a dialog asking to open as project or import models
self.callLater(self.openProjectFile.emit, file, add_to_recent_files)
return
@ -1999,8 +2000,11 @@ class CuraApplication(QtApplication):
center_y = 0
node.translate(Vector(0, center_y, 0))
nodes_to_arrange.append(node)
# If file extention is 3mf and models are to be loaded from a cura project,
# models are to be arranged in buildplate.
elif self._project_mode == "open_as_model":
nodes_to_arrange.append(node)
# This node is deep copied from some other node which already has a BuildPlateDecorator, but the deepcopy
# of BuildPlateDecorator produces one that's associated with build plate -1. So, here we need to check if