Expose approximateMaterialDiameter of the definition

This way we can request that from QML.

Contributes to issue CURA-2822.
This commit is contained in:
Ghostkeeper 2017-06-22 11:17:34 +02:00
parent 503aa00137
commit fc96dfec4e
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75
2 changed files with 37 additions and 0 deletions

View file

@ -107,6 +107,21 @@ class GlobalStack(CuraContainerStack):
def setNextStack(self, next_stack: ContainerStack) -> None:
raise Exceptions.InvalidOperationError("Global stack cannot have a next stack!")
## Gets the approximate filament diameter that the machine requires.
#
# The approximate material diameter is the material diameter rounded to
# the nearest millimetre.
#
# If the machine has no requirement for the diameter, -1 is returned.
#
# \return The approximate filament diameter for the printer, as a string.
@pyqtProperty(str)
def approximateMaterialDiameter(self) -> str:
material_diameter = self.definition.getMetaDataEntry("material_diameter")
if material_diameter is None:
return "-1"
return str(round(float(self.definition.getMetaDataEntry("material_diameter")))) #Round, then convert back to string.
# protected:
# Determine whether or not we should try to get the "resolve" property instead of the