mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-03 12:03:57 -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 uuid
|
||||
from typing import Any
|
||||
from typing import Dict, Union
|
||||
from typing import Dict, Union, Optional
|
||||
|
||||
from PyQt5.QtCore import QObject, QUrl, QVariant
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
@ -46,13 +46,18 @@ class ContainerManager(QObject):
|
|||
self._quality_manager = self._application.getQualityManager()
|
||||
self._container_name_filters = {} # type: Dict[str, Dict[str, Any]]
|
||||
|
||||
@pyqtSlot(str, str, result=str)
|
||||
def getContainerMetaDataEntry(self, container_id, entry_name):
|
||||
@pyqtSlot(str, str, str, result=str)
|
||||
def getContainerMetaDataEntry(self, container_id, entry_name, sub_entry: Optional = None):
|
||||
metadatas = self._container_registry.findContainersMetadata(id = container_id)
|
||||
if not metadatas:
|
||||
Logger.log("w", "Could not get metadata of container %s because it was not found.", container_id)
|
||||
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, ""))
|
||||
|
||||
## Set a metadata entry of the specified container.
|
||||
|
|
|
@ -529,6 +529,12 @@ TabView
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue