mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 14:37:29 -06:00
Also move printer name mapping to new FormatMaps utility.
done as part of CURA-12005
This commit is contained in:
parent
f81a3f0e11
commit
ddf4f4c6fe
3 changed files with 31 additions and 26 deletions
|
@ -17,6 +17,7 @@ from UM.Settings.ContainerRegistry import ContainerRegistry
|
|||
from UM.ConfigurationErrorMessage import ConfigurationErrorMessage
|
||||
|
||||
from cura.CuraApplication import CuraApplication
|
||||
from cura.PrinterOutput.FormatMaps import FormatMaps
|
||||
from cura.Machines.VariantType import VariantType
|
||||
|
||||
try:
|
||||
|
@ -249,7 +250,7 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
machine_variant_map[definition_id][variant_name] = variant_dict
|
||||
|
||||
# Map machine human-readable names to IDs
|
||||
product_id_map = self.getProductIdMap()
|
||||
product_id_map = FormatMaps.getProductIdMap()
|
||||
|
||||
for definition_id, container in machine_container_map.items():
|
||||
definition_id = container.getMetaDataEntry("definition")
|
||||
|
@ -647,7 +648,7 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
self._dirty = False
|
||||
|
||||
# Map machine human-readable names to IDs
|
||||
product_id_map = self.getProductIdMap()
|
||||
product_id_map = FormatMaps.getProductIdMap()
|
||||
|
||||
machines = data.iterfind("./um:settings/um:machine", self.__namespaces)
|
||||
for machine in machines:
|
||||
|
@ -923,7 +924,7 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
result_metadata.append(base_metadata)
|
||||
|
||||
# Map machine human-readable names to IDs
|
||||
product_id_map = cls.getProductIdMap()
|
||||
product_id_map = FormatMaps.getProductIdMap()
|
||||
|
||||
for machine in data.iterfind("./um:settings/um:machine", cls.__namespaces):
|
||||
machine_compatibility = common_compatibility
|
||||
|
@ -1128,29 +1129,6 @@ class XmlMaterialProfile(InstanceContainer):
|
|||
id_list = list(id_list)
|
||||
return id_list
|
||||
|
||||
__product_to_id_map: Optional[Dict[str, List[str]]] = None
|
||||
|
||||
@classmethod
|
||||
def getProductIdMap(cls) -> Dict[str, List[str]]:
|
||||
"""Gets a mapping from product names in the XML files to their definition IDs.
|
||||
|
||||
This loads the mapping from a file.
|
||||
"""
|
||||
if cls.__product_to_id_map is not None:
|
||||
return cls.__product_to_id_map
|
||||
|
||||
plugin_path = cast(str, PluginRegistry.getInstance().getPluginPath("XmlMaterialProfile"))
|
||||
product_to_id_file = os.path.join(plugin_path, "product_to_id.json")
|
||||
with open(product_to_id_file, encoding = "utf-8") as f:
|
||||
contents = ""
|
||||
for line in f:
|
||||
contents += line if "#" not in line else "".join([line.replace("#", str(n)) for n in range(1, 12)])
|
||||
cls.__product_to_id_map = json.loads(contents)
|
||||
cls.__product_to_id_map = {key: [value] for key, value in cls.__product_to_id_map.items()}
|
||||
#This also loads "Ultimaker S5" -> "ultimaker_s5" even though that is not strictly necessary with the default to change spaces into underscores.
|
||||
#However it is not always loaded with that default; this mapping is also used in serialize() without that default.
|
||||
return cls.__product_to_id_map
|
||||
|
||||
@staticmethod
|
||||
def _parseCompatibleValue(value: str):
|
||||
"""Parse the value of the "material compatible" property."""
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"Ultimaker #": "ultimaker#",
|
||||
"Ultimaker # Extended": "ultimaker#_extended",
|
||||
"Ultimaker # Extended+": "ultimaker#_extended_plus",
|
||||
"Ultimaker # Go": "ultimaker#_go",
|
||||
"Ultimaker #+": "ultimaker#_plus",
|
||||
"Ultimaker #+ Connect": "ultimaker#_plus_connect",
|
||||
"Ultimaker S#": "ultimaker_s#",
|
||||
"Ultimaker Factor #": "ultimaker_factor#",
|
||||
"Ultimaker Original": "ultimaker_original",
|
||||
"Ultimaker Original+": "ultimaker_original_plus",
|
||||
"Ultimaker Original Dual Extrusion": "ultimaker_original_dual",
|
||||
"IMADE3D JellyBOX": "imade3d_jellybox",
|
||||
"DUAL600": "strateo3d",
|
||||
"IDEX420": "strateo3d_IDEX420",
|
||||
"IDEX420 Duplicate": "strateo3d_IDEX420_duplicate",
|
||||
"IDEX420 Mirror": "strateo3d_IDEX420_mirror",
|
||||
"UltiMaker Method": "ultimaker_method",
|
||||
"UltiMaker Method X": "ultimaker_methodx",
|
||||
"UltiMaker Method XL": "ultimaker_methodxl",
|
||||
"UltiMaker Sketch": "ultimaker_sketch",
|
||||
"UltiMaker Sketch Large": "ultimaker_sketch_large"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue