mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 06:57:28 -06:00
Add material information to ufp output
CURA-9224
This commit is contained in:
parent
599fddd6dd
commit
880724d2e4
1 changed files with 16 additions and 9 deletions
|
@ -27,7 +27,7 @@ from cura.Utils.Threading import call_on_qt_thread
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
|
||||||
METADATA_OBJECTS_PATH = "metadata/objects"
|
METADATA_OBJECTS_PATH = "metadata/objects"
|
||||||
SETTINGS_PATH = "Cura/settings.json"
|
SLICE_METADATA_PATH = "Cura/slicemetadata.json"
|
||||||
|
|
||||||
catalog = i18nCatalog("cura")
|
catalog = i18nCatalog("cura")
|
||||||
|
|
||||||
|
@ -83,9 +83,9 @@ class UFPWriter(MeshWriter):
|
||||||
try:
|
try:
|
||||||
archive.addContentType(extension="json", mime_type="application/json")
|
archive.addContentType(extension="json", mime_type="application/json")
|
||||||
setting_textio = StringIO()
|
setting_textio = StringIO()
|
||||||
json.dump(self._getSettings(), setting_textio, separators=(", ", ": "), indent=4)
|
json.dump(self._getSliceMetadata(), setting_textio, separators=(", ", ": "), indent=4)
|
||||||
settings = archive.getStream(SETTINGS_PATH)
|
steam = archive.getStream(SLICE_METADATA_PATH)
|
||||||
settings.write(setting_textio.getvalue().encode("UTF-8"))
|
steam.write(setting_textio.getvalue().encode("UTF-8"))
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
error_msg = catalog.i18nc("@info:error", "Can't write to UFP file:") + " " + str(e)
|
error_msg = catalog.i18nc("@info:error", "Can't write to UFP file:") + " " + str(e)
|
||||||
self.setInformation(error_msg)
|
self.setInformation(error_msg)
|
||||||
|
@ -213,12 +213,18 @@ class UFPWriter(MeshWriter):
|
||||||
for item in DepthFirstIterator(node)
|
for item in DepthFirstIterator(node)
|
||||||
if item.getMeshData() is not None and not item.callDecoration("isNonPrintingMesh")]
|
if item.getMeshData() is not None and not item.callDecoration("isNonPrintingMesh")]
|
||||||
|
|
||||||
def _getSettings(self) -> Dict[str, Dict[str, Dict[str, str]]]:
|
def _getSliceMetadata(self) -> Dict[str, Dict[str, Dict[str, str]]]:
|
||||||
"""Get all changed settings and all settings. For each extruder and the global stack"""
|
"""Get all changed settings and all settings. For each extruder and the global stack"""
|
||||||
|
print_information = CuraApplication.getInstance().getPrintInformation()
|
||||||
settings = {
|
settings = {
|
||||||
|
"material": {
|
||||||
|
"length": print_information.materialLengths,
|
||||||
|
"weight": print_information.materialWeights,
|
||||||
|
"cost": print_information.materialCosts,
|
||||||
|
},
|
||||||
"global": {
|
"global": {
|
||||||
"changes": {},
|
"changes": {},
|
||||||
"all_settings": {}
|
"all_settings": {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,9 +241,10 @@ class UFPWriter(MeshWriter):
|
||||||
|
|
||||||
for i, extruder in enumerate(global_stack.extruderList):
|
for i, extruder in enumerate(global_stack.extruderList):
|
||||||
# Add extruder fields to settings dictionary
|
# Add extruder fields to settings dictionary
|
||||||
settings[f"extruder_{i}"] = {}
|
settings[f"extruder_{i}"] = {
|
||||||
settings[f"extruder_{i}"]["changes"] = {}
|
"changes": {},
|
||||||
settings[f"extruder_{i}"]["all_settings"] = {}
|
"all_settings": {},
|
||||||
|
}
|
||||||
|
|
||||||
# Add extruder user or quality changes
|
# Add extruder user or quality changes
|
||||||
extruder_flattened_changes = CuraStackBuilder.createFlattenedContainerInstance(extruder.userChanges, extruder.qualityChanges)
|
extruder_flattened_changes = CuraStackBuilder.createFlattenedContainerInstance(extruder.userChanges, extruder.qualityChanges)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue