mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-20 17:49:14 +08:00
CURA-4776 Add unique id to the profiles so user can import the same
profile several times with different names.It also fixes the issue for importing profiles from GCode.
This commit is contained in:
parent
d91a2e1ca3
commit
78b42afbcb
@ -214,8 +214,6 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
name_seed = os.path.splitext(os.path.basename(file_name))[0]
|
name_seed = os.path.splitext(os.path.basename(file_name))[0]
|
||||||
new_name = self.uniqueName(name_seed)
|
new_name = self.uniqueName(name_seed)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Ensure it is always a list of profiles
|
# Ensure it is always a list of profiles
|
||||||
if type(profile_or_list) is not list:
|
if type(profile_or_list) is not list:
|
||||||
profile_or_list = [profile_or_list]
|
profile_or_list = [profile_or_list]
|
||||||
@ -238,16 +236,6 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
else: #More extruders in the imported file than in the machine.
|
else: #More extruders in the imported file than in the machine.
|
||||||
continue #Delete the additional profiles.
|
continue #Delete the additional profiles.
|
||||||
|
|
||||||
# if the loaded profile comes from g-code then the instance containers should be
|
|
||||||
# defined differently
|
|
||||||
if extension == "gcode":
|
|
||||||
if profile.getMetaDataEntry("extruder") is None:
|
|
||||||
temp_defintion = profile.getMetaDataEntry("definition")
|
|
||||||
profile.metaData["id"] = (temp_defintion + "_" + new_name).lower()
|
|
||||||
elif profile.getMetaDataEntry("extruder") is not None: # be sure that extruder data exist
|
|
||||||
temp_extruder = profile.getMetaDataEntry("extruder")
|
|
||||||
profile.metaData["id"] = (temp_extruder + "_" + new_name).lower()
|
|
||||||
|
|
||||||
result = self._configureProfile(profile, profile_id, new_name)
|
result = self._configureProfile(profile, profile_id, new_name)
|
||||||
if result is not None:
|
if result is not None:
|
||||||
return {"status": "error", "message": catalog.i18nc(
|
return {"status": "error", "message": catalog.i18nc(
|
||||||
@ -280,6 +268,10 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
profile._id = new_id
|
profile._id = new_id
|
||||||
profile.setName(new_name)
|
profile.setName(new_name)
|
||||||
|
|
||||||
|
# Set the unique Id to the profile, so it's generating a new one even if the user imports the same profile
|
||||||
|
# It also solves an issue with importing profiles from G-Codes
|
||||||
|
profile.setMetaDataEntry("id", new_id)
|
||||||
|
|
||||||
if "type" in profile.getMetaData():
|
if "type" in profile.getMetaData():
|
||||||
profile.setMetaDataEntry("type", "quality_changes")
|
profile.setMetaDataEntry("type", "quality_changes")
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user