CURA-4461 Store buildplate compatibility in the material profile

This commit is contained in:
Diego Prado Gesto 2018-01-15 14:31:52 +01:00
parent 67ca4d25cd
commit badf5a9043

View File

@ -606,8 +606,11 @@ class XmlMaterialProfile(InstanceContainer):
if is_new_material:
containers_to_add.append(new_material)
# Find the buildplates compatibility
buildplates = machine.iterfind("./um:buildplate", self.__namespaces)
buildplate_map = {}
buildplate_map["buildplate_compatible"] = {}
buildplate_map["buildplate_recommended"] = {}
for buildplate in buildplates:
buildplate_id = buildplate.get("id")
if buildplate_id is None:
@ -636,14 +639,8 @@ class XmlMaterialProfile(InstanceContainer):
else:
Logger.log("d", "Unsupported material setting %s", key)
buildplate_map[buildplate_id] = {}
buildplate_map[buildplate_id]["buildplate_compatible"] = buildplate_compatibility
buildplate_map[buildplate_id]["buildplate_recommended"] = buildplate_recommended
# If no buildplate was found, then the material is created without buildplate information
if not buildplate_map:
buildplate_map[""] = {"buildplate_compatible" : machine_compatibility,
"buildplate_recommended" : machine_compatibility}
buildplate_map["buildplate_compatible"][buildplate_id] = buildplate_compatibility
buildplate_map["buildplate_recommended"][buildplate_id] = buildplate_recommended
hotends = machine.iterfind("./um:hotend", self.__namespaces)
for hotend in hotends:
@ -672,16 +669,9 @@ class XmlMaterialProfile(InstanceContainer):
else:
Logger.log("d", "Unsupported material setting %s", key)
for buildplate_id in buildplate_map:
new_hotend_id = self.getId() + "_" + machine_id + "_" + hotend_id.replace(" ", "_")
new_hotend_id = self.getId() + "_" + machine_id + ("_" if buildplate_id != "" else "") + \
buildplate_id.replace(" ", "_") + "_" + hotend_id.replace(" ", "_")
buildplate_compatibility = buildplate_map[buildplate_id]["buildplate_compatible"]
buildplate_recommended = buildplate_map[buildplate_id]["buildplate_recommended"]
# Same as machine compatibility, keep the derived material containers consistent with the parent
# material
# Same as machine compatibility, keep the derived material containers consistent with the parent material
if ContainerRegistry.getInstance().isLoaded(new_hotend_id):
new_hotend_material = ContainerRegistry.getInstance().findContainers(id = new_hotend_id)[0]
is_new_material = False
@ -696,12 +686,11 @@ class XmlMaterialProfile(InstanceContainer):
new_hotend_material.setDefinition(machine_id)
# Don't use setMetadata, as that overrides it for all materials with same base file
new_hotend_material.getMetaData()["compatible"] = hotend_compatibility
new_hotend_material.getMetaData()["buildplate_compatible"] = buildplate_compatibility
new_hotend_material.getMetaData()["buildplate_recommended"] = buildplate_recommended
new_hotend_material.getMetaData()["machine_manufacturer"] = machine_manufacturer
new_hotend_material.getMetaData()["definition"] = machine_id
# if machine_id == "ultimaker3_xl" and self.getId() == "generic_abs":
# print("&&&&&&&&&&&& HotendID", new_hotend_id)
if buildplate_map["buildplate_compatible"]:
new_hotend_material.getMetaData()["buildplate_compatible"] = buildplate_map["buildplate_compatible"]
new_hotend_material.getMetaData()["buildplate_recommended"] = buildplate_map["buildplate_recommended"]
cached_hotend_setting_properties = cached_machine_setting_properties.copy()
cached_hotend_setting_properties.update(hotend_setting_values)
@ -844,6 +833,8 @@ class XmlMaterialProfile(InstanceContainer):
buildplates = machine.iterfind("./um:buildplate", cls.__namespaces)
buildplate_map = {}
buildplate_map["buildplate_compatible"] = {}
buildplate_map["buildplate_recommended"] = {}
for buildplate in buildplates:
buildplate_id = buildplate.get("id")
if buildplate_id is None:
@ -857,8 +848,6 @@ class XmlMaterialProfile(InstanceContainer):
if not variant_containers:
continue
buildplate_compatibility = machine_compatibility
buildplate_recommended = machine_compatibility
settings = buildplate.iterfind("./um:setting", cls.__namespaces)
for entry in settings:
key = entry.get("key")
@ -867,14 +856,8 @@ class XmlMaterialProfile(InstanceContainer):
elif key == "hardware recommended":
buildplate_recommended = cls._parseCompatibleValue(entry.text)
buildplate_map[buildplate_id] = {}
buildplate_map[buildplate_id]["buildplate_compatible"] = buildplate_compatibility
buildplate_map[buildplate_id]["buildplate_recommended"] = buildplate_recommended
# If no buildplate was found, then the material is created without buildplate information
if not buildplate_map:
buildplate_map[""] = {"buildplate_compatible": machine_compatibility,
"buildplate_recommended": machine_compatibility}
buildplate_map["buildplate_compatible"][buildplate_id] = buildplate_map["buildplate_compatible"]
buildplate_map["buildplate_recommended"][buildplate_id] = buildplate_map["buildplate_recommended"]
for hotend in machine.iterfind("./um:hotend", cls.__namespaces):
hotend_id = hotend.get("id")
@ -892,13 +875,7 @@ class XmlMaterialProfile(InstanceContainer):
if key == "hardware compatible":
hotend_compatibility = cls._parseCompatibleValue(entry.text)
for buildplate_id in buildplate_map:
new_hotend_id = container_id + "_" + machine_id + ("_" if buildplate_id != "" else "") + \
buildplate_id.replace(" ", "_") + "_" + hotend_id.replace(" ", "_")
buildplate_compatibility = buildplate_map[buildplate_id]["buildplate_compatible"]
buildplate_recommended = buildplate_map[buildplate_id]["buildplate_recommended"]
new_hotend_id = container_id + "_" + machine_id + "_" + hotend_id.replace(" ", "_")
# Same as machine compatibility, keep the derived material containers consistent with the parent material
found_materials = ContainerRegistry.getInstance().findInstanceContainersMetadata(id = new_hotend_id)
@ -914,13 +891,12 @@ class XmlMaterialProfile(InstanceContainer):
new_hotend_material_metadata["variant"] = hotend_id
_with_missing_variants.append(new_hotend_material_metadata)
new_hotend_material_metadata["compatible"] = hotend_compatibility
new_hotend_material_metadata["buildplate_compatible"] = buildplate_compatibility
new_hotend_material_metadata["buildplate_recommended"] = buildplate_recommended
new_hotend_material_metadata["machine_manufacturer"] = machine_manufacturer
new_hotend_material_metadata["id"] = new_hotend_id
new_hotend_material_metadata["definition"] = machine_id
# if machine_id == "ultimaker3_xl" and container_id == "generic_abs":
# print("############# HotendID", new_hotend_id)
if buildplate_map["buildplate_compatible"]:
new_hotend_material_metadata["buildplate_compatible"] = buildplate_map["buildplate_compatible"]
new_hotend_material_metadata["buildplate_recommended"] = buildplate_map["buildplate_recommended"]
if len(found_materials) == 0:
result_metadata.append(new_hotend_material_metadata)