Generate new unique names for new machines from the project files

CURA-4144

Generate a new name for the machine loaded from a project file instead
of using new ID as the new name.
This commit is contained in:
Lipu Fei 2017-08-16 08:30:11 +02:00
parent 6177c42f0d
commit 4ad62daf61

View file

@ -438,6 +438,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
global_stack_id_original = self._stripFileToId(global_stack_file)
global_stack_id_new = global_stack_id_original
global_stack_name_original = self._getMachineNameFromSerializedStack(archive.open(global_stack_file).read().decode("utf-8"))
global_stack_name_new = global_stack_name_original
global_stack_need_rename = False
extruder_stack_id_map = {} # new and old ExtruderStack IDs map
@ -447,6 +449,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
global_stack_id_new = self.getNewId(global_stack_id_original)
global_stack_need_rename = True
global_stack_name_new = self._container_registry.uniqueName(global_stack_name_original)
for each_extruder_stack_file in extruder_stack_files:
old_container_id = self._stripFileToId(each_extruder_stack_file)
new_container_id = old_container_id
@ -656,6 +660,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
if stack.getMetaDataEntry("machine", None):
stack.setMetaDataEntry("machine", global_stack_id_new)
# Only machines need a new name, stacks may be non-unique
stack.setName(global_stack_name_new)
container_stacks_added.append(stack)
self._container_registry.addContainer(stack)
containers_added.append(stack)