mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 11:15:54 +08:00
Expose an extruderValue() function to value functions
It returns the value of a setting of a specific extruder. Contributes to CURA-2009
This commit is contained in:
parent
b102a6cedd
commit
3c35830cb8
@ -101,6 +101,8 @@ class CuraApplication(QtApplication):
|
||||
SettingDefinition.addSettingType("extruder", None, str, Validator)
|
||||
|
||||
SettingFunction.registerOperator("extruderValues", cura.Settings.ExtruderManager.getExtruderValues)
|
||||
SettingFunction.registerOperator("extruderValue", cura.Settings.ExtruderManager.getExtruderValue)
|
||||
|
||||
## Add the 4 types of profiles to storage.
|
||||
Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality")
|
||||
Resources.addStorageType(self.ResourceTypes.VariantInstanceContainer, "variants")
|
||||
|
@ -6,6 +6,7 @@ from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot, QObject, QVariant #
|
||||
import UM.Application #To get the global container stack to find the current machine.
|
||||
import UM.Logger
|
||||
import UM.Settings.ContainerRegistry #Finding containers by ID.
|
||||
import UM.Settings.SettingFunction
|
||||
|
||||
|
||||
## Manages all existing extruder stacks.
|
||||
@ -92,6 +93,15 @@ class ExtruderManager(QObject):
|
||||
return self._extruder_trains[global_container_stack.getId()][str(self._active_extruder_index)]
|
||||
return None
|
||||
|
||||
## Get an extruder stack by index
|
||||
def getExtruderStack(self, index):
|
||||
global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||
if global_container_stack:
|
||||
if global_container_stack.getId() in self._extruder_trains:
|
||||
if str(index) in self._extruder_trains[global_container_stack.getId()]:
|
||||
return self._extruder_trains[global_container_stack.getId()][str(index)]
|
||||
return None
|
||||
|
||||
## Adds all extruders of a specific machine definition to the extruder
|
||||
# manager.
|
||||
#
|
||||
@ -295,3 +305,10 @@ class ExtruderManager(QObject):
|
||||
|
||||
return result
|
||||
|
||||
@staticmethod
|
||||
def getExtruderValue(extruder_index, name):
|
||||
extruder = ExtruderManager.getInstance().getExtruderStack(extruder_index)
|
||||
if extruder:
|
||||
return extruder.getRawProperty(name, "value", use_next = False)
|
||||
|
||||
return None
|
||||
|
Loading…
x
Reference in New Issue
Block a user