MachineModelUtils.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # Copyright (c) 2021 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import TYPE_CHECKING
  4. from UM.Settings.SettingFunction import SettingFunction
  5. if TYPE_CHECKING:
  6. from cura.Machines.QualityGroup import QualityGroup
  7. layer_height_unit = ""
  8. def fetchLayerHeight(quality_group: "QualityGroup") -> float:
  9. from cura.CuraApplication import CuraApplication
  10. global_stack = CuraApplication.getInstance().getMachineManager().activeMachine
  11. default_layer_height = global_stack.definition.getProperty("layer_height", "value")
  12. # Get layer_height from the quality profile for the GlobalStack
  13. if quality_group.node_for_global is None:
  14. return float(default_layer_height)
  15. container = quality_group.node_for_global.container
  16. layer_height = default_layer_height
  17. if container and container.hasProperty("layer_height", "value"):
  18. layer_height = container.getProperty("layer_height", "value")
  19. else:
  20. # Look for layer_height in the GlobalStack from material -> definition
  21. container = global_stack.definition
  22. if container and container.hasProperty("layer_height", "value"):
  23. layer_height = container.getProperty("layer_height", "value")
  24. if isinstance(layer_height, SettingFunction):
  25. layer_height = layer_height(global_stack)
  26. return round(float(layer_height), 3)