mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 23:53:56 -06:00
Read material weight from container
CURA-5408
This commit is contained in:
parent
183cd0182d
commit
77bd6cf749
2 changed files with 14 additions and 3 deletions
|
@ -5,7 +5,7 @@ import os
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict, Union
|
from typing import Dict, Union, Optional
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, QUrl, QVariant
|
from PyQt5.QtCore import QObject, QUrl, QVariant
|
||||||
from PyQt5.QtWidgets import QMessageBox
|
from PyQt5.QtWidgets import QMessageBox
|
||||||
|
@ -46,13 +46,18 @@ class ContainerManager(QObject):
|
||||||
self._quality_manager = self._application.getQualityManager()
|
self._quality_manager = self._application.getQualityManager()
|
||||||
self._container_name_filters = {} # type: Dict[str, Dict[str, Any]]
|
self._container_name_filters = {} # type: Dict[str, Dict[str, Any]]
|
||||||
|
|
||||||
@pyqtSlot(str, str, result=str)
|
@pyqtSlot(str, str, str, result=str)
|
||||||
def getContainerMetaDataEntry(self, container_id, entry_name):
|
def getContainerMetaDataEntry(self, container_id, entry_name, sub_entry: Optional = None):
|
||||||
metadatas = self._container_registry.findContainersMetadata(id = container_id)
|
metadatas = self._container_registry.findContainersMetadata(id = container_id)
|
||||||
if not metadatas:
|
if not metadatas:
|
||||||
Logger.log("w", "Could not get metadata of container %s because it was not found.", container_id)
|
Logger.log("w", "Could not get metadata of container %s because it was not found.", container_id)
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
if sub_entry != "":
|
||||||
|
sub_data = metadatas[0].get(entry_name, "")
|
||||||
|
if sub_data:
|
||||||
|
return str(sub_data.get(sub_entry, ""))
|
||||||
|
|
||||||
return str(metadatas[0].get(entry_name, ""))
|
return str(metadatas[0].get(entry_name, ""))
|
||||||
|
|
||||||
## Set a metadata entry of the specified container.
|
## Set a metadata entry of the specified container.
|
||||||
|
|
|
@ -529,6 +529,12 @@ TabView
|
||||||
{
|
{
|
||||||
return materialPreferenceValues[material_guid][entry_name];
|
return materialPreferenceValues[material_guid][entry_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var material_weight = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties", "weight");
|
||||||
|
if(material_weight != undefined && material_weight != "")
|
||||||
|
{
|
||||||
|
return material_weight
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue