|
@@ -122,26 +122,6 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|
if len(all_quality_changes) <= 1 and not parser.has_option("metadata", "extruder"):
|
|
if len(all_quality_changes) <= 1 and not parser.has_option("metadata", "extruder"):
|
|
self._createExtruderQualityChangesForSingleExtrusionMachine(filename, parser)
|
|
self._createExtruderQualityChangesForSingleExtrusionMachine(filename, parser)
|
|
|
|
|
|
- if parser["metadata"]["type"] == "definition_changes":
|
|
|
|
- if parser["general"]["definition"] == "custom":
|
|
|
|
-
|
|
|
|
- # We are only interested in machine_nozzle_size
|
|
|
|
- if parser.has_option("values", "machine_nozzle_size"):
|
|
|
|
- machine_nozzle_size = parser["values"]["machine_nozzle_size"]
|
|
|
|
-
|
|
|
|
- machine_extruder_count = '1' # by default it is 1 and the value cannot be stored in the global stack
|
|
|
|
- if parser.has_option("values", "machine_extruder_count"):
|
|
|
|
- machine_extruder_count = parser["values"]["machine_extruder_count"]
|
|
|
|
-
|
|
|
|
- if machine_extruder_count == '1':
|
|
|
|
- definition_name = parser["general"]["name"]
|
|
|
|
- machine_extruders = self._getSingleExtrusionMachineExtruders(definition_name)
|
|
|
|
-
|
|
|
|
- # For single extruder machine we need only first extruder
|
|
|
|
- if len(machine_extruders) != 0:
|
|
|
|
- self._updateSingleExtruderDefinitionFile(machine_extruders, machine_nozzle_size)
|
|
|
|
- parser.remove_option("values", "machine_nozzle_size")
|
|
|
|
-
|
|
|
|
# Update version numbers
|
|
# Update version numbers
|
|
parser["general"]["version"] = "2"
|
|
parser["general"]["version"] = "2"
|
|
parser["metadata"]["setting_version"] = "4"
|
|
parser["metadata"]["setting_version"] = "4"
|
|
@@ -220,123 +200,6 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|
|
|
|
|
return quality_changes_containers
|
|
return quality_changes_containers
|
|
|
|
|
|
- def _getSingleExtrusionMachineExtruders(self, definition_name):
|
|
|
|
-
|
|
|
|
- machine_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.MachineStack)
|
|
|
|
-
|
|
|
|
- machine_instance_id = None
|
|
|
|
-
|
|
|
|
- # Find machine instances
|
|
|
|
- for item in os.listdir(machine_instances_dir):
|
|
|
|
- file_path = os.path.join(machine_instances_dir, item)
|
|
|
|
- if not os.path.isfile(file_path):
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- parser = configparser.ConfigParser(interpolation=None)
|
|
|
|
- try:
|
|
|
|
- parser.read([file_path])
|
|
|
|
- except:
|
|
|
|
- # skip, it is not a valid stack file
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- if not parser.has_option("metadata", "type"):
|
|
|
|
- continue
|
|
|
|
- if "machine" != parser["metadata"]["type"]:
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- if not parser.has_option("general", "id"):
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- id = parser["general"]["id"]
|
|
|
|
- if id + "_settings" != definition_name:
|
|
|
|
- continue
|
|
|
|
- else:
|
|
|
|
- machine_instance_id = id
|
|
|
|
- break
|
|
|
|
-
|
|
|
|
- if machine_instance_id is not None:
|
|
|
|
-
|
|
|
|
- extruders_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.ExtruderStack)
|
|
|
|
- #"machine",[extruders]
|
|
|
|
- extruder_instances = []
|
|
|
|
-
|
|
|
|
- # Find all custom extruders for found machines
|
|
|
|
- for item in os.listdir(extruders_instances_dir):
|
|
|
|
- file_path = os.path.join(extruders_instances_dir, item)
|
|
|
|
- if not os.path.isfile(file_path):
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- parser = configparser.ConfigParser(interpolation=None)
|
|
|
|
- try:
|
|
|
|
- parser.read([file_path])
|
|
|
|
- except:
|
|
|
|
- # skip, it is not a valid stack file
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- if not parser.has_option("metadata", "type"):
|
|
|
|
- continue
|
|
|
|
- if "extruder_train" != parser["metadata"]["type"]:
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- if not parser.has_option("metadata", "machine"):
|
|
|
|
- continue
|
|
|
|
- if not parser.has_option("metadata", "position"):
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- if machine_instance_id != parser["metadata"]["machine"]:
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- extruder_instances.append(parser)
|
|
|
|
-
|
|
|
|
- return extruder_instances
|
|
|
|
-
|
|
|
|
- # Find extruder definition at index 0 and update its values
|
|
|
|
- def _updateSingleExtruderDefinitionFile(self, extruder_instances_per_machine, machine_nozzle_size):
|
|
|
|
-
|
|
|
|
- defintion_instances_dir = Resources.getPath(CuraApplication.ResourceTypes.DefinitionChangesContainer)
|
|
|
|
-
|
|
|
|
- for item in os.listdir(defintion_instances_dir):
|
|
|
|
- file_path = os.path.join(defintion_instances_dir, item)
|
|
|
|
- if not os.path.isfile(file_path):
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- parser = configparser.ConfigParser(interpolation=None)
|
|
|
|
- try:
|
|
|
|
- parser.read([file_path])
|
|
|
|
- except:
|
|
|
|
- # skip, it is not a valid stack file
|
|
|
|
- continue
|
|
|
|
-
|
|
|
|
- if not parser.has_option("general", "name"):
|
|
|
|
- continue
|
|
|
|
- name = parser["general"]["name"]
|
|
|
|
- custom_extruder_at_0_position = None
|
|
|
|
- for extruder_instance in extruder_instances_per_machine:
|
|
|
|
-
|
|
|
|
- definition_position = extruder_instance["metadata"]["position"]
|
|
|
|
-
|
|
|
|
- if definition_position == "0":
|
|
|
|
- custom_extruder_at_0_position = extruder_instance
|
|
|
|
- break
|
|
|
|
-
|
|
|
|
- # If not null, then parsed file is for first extuder and then can be updated. I need to update only
|
|
|
|
- # first, because this update for single extuder machine
|
|
|
|
- if custom_extruder_at_0_position is not None:
|
|
|
|
-
|
|
|
|
- #Add new value
|
|
|
|
- parser["values"]["machine_nozzle_size"] = machine_nozzle_size
|
|
|
|
-
|
|
|
|
- definition_output = io.StringIO()
|
|
|
|
- parser.write(definition_output)
|
|
|
|
-
|
|
|
|
- with open(file_path, "w") as f:
|
|
|
|
- f.write(definition_output.getvalue())
|
|
|
|
-
|
|
|
|
- return True
|
|
|
|
-
|
|
|
|
- return False
|
|
|
|
-
|
|
|
|
-
|
|
|
|
def _createExtruderQualityChangesForSingleExtrusionMachine(self, filename, global_quality_changes):
|
|
def _createExtruderQualityChangesForSingleExtrusionMachine(self, filename, global_quality_changes):
|
|
suffix = "_" + quote_plus(global_quality_changes["general"]["name"].lower())
|
|
suffix = "_" + quote_plus(global_quality_changes["general"]["name"].lower())
|
|
machine_name = os.path.os.path.basename(filename).replace(".inst.cfg", "").replace(suffix, "")
|
|
machine_name = os.path.os.path.basename(filename).replace(".inst.cfg", "").replace(suffix, "")
|
|
@@ -369,4 +232,4 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|
quality_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.QualityInstanceContainer)
|
|
quality_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.QualityInstanceContainer)
|
|
|
|
|
|
with open(os.path.join(quality_changes_dir, extruder_quality_changes_filename), "w") as f:
|
|
with open(os.path.join(quality_changes_dir, extruder_quality_changes_filename), "w") as f:
|
|
- f.write(extruder_quality_changes_output.getvalue())
|
|
|
|
|
|
+ f.write(extruder_quality_changes_output.getvalue())
|