mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 04:37:51 -06:00
Expose an extruderValues() function to value functions
It returns a list of values for all extruders so that things like max() work. Contributes to CURA-2009
This commit is contained in:
parent
f568014e67
commit
b102a6cedd
2 changed files with 24 additions and 1 deletions
|
@ -28,6 +28,7 @@ from cura.SetParentOperation import SetParentOperation
|
||||||
|
|
||||||
from UM.Settings.SettingDefinition import SettingDefinition, DefinitionPropertyType
|
from UM.Settings.SettingDefinition import SettingDefinition, DefinitionPropertyType
|
||||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||||
|
from UM.Settings.SettingFunction import SettingFunction
|
||||||
|
|
||||||
from UM.i18n import i18nCatalog
|
from UM.i18n import i18nCatalog
|
||||||
|
|
||||||
|
@ -71,7 +72,6 @@ except ImportError:
|
||||||
CuraVersion = "master" # [CodeStyle: Reflecting imported value]
|
CuraVersion = "master" # [CodeStyle: Reflecting imported value]
|
||||||
CuraBuildType = ""
|
CuraBuildType = ""
|
||||||
|
|
||||||
|
|
||||||
class CuraApplication(QtApplication):
|
class CuraApplication(QtApplication):
|
||||||
class ResourceTypes:
|
class ResourceTypes:
|
||||||
QmlFiles = Resources.UserType + 1
|
QmlFiles = Resources.UserType + 1
|
||||||
|
@ -100,6 +100,7 @@ class CuraApplication(QtApplication):
|
||||||
SettingDefinition.addSupportedProperty("global_inherits_stack", DefinitionPropertyType.Function, default = "-1")
|
SettingDefinition.addSupportedProperty("global_inherits_stack", DefinitionPropertyType.Function, default = "-1")
|
||||||
SettingDefinition.addSettingType("extruder", None, str, Validator)
|
SettingDefinition.addSettingType("extruder", None, str, Validator)
|
||||||
|
|
||||||
|
SettingFunction.registerOperator("extruderValues", cura.Settings.ExtruderManager.getExtruderValues)
|
||||||
## Add the 4 types of profiles to storage.
|
## Add the 4 types of profiles to storage.
|
||||||
Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality")
|
Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality")
|
||||||
Resources.addStorageType(self.ResourceTypes.VariantInstanceContainer, "variants")
|
Resources.addStorageType(self.ResourceTypes.VariantInstanceContainer, "variants")
|
||||||
|
|
|
@ -273,3 +273,25 @@ class ExtruderManager(QObject):
|
||||||
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||||
if global_stack and global_stack.getBottom():
|
if global_stack and global_stack.getBottom():
|
||||||
self.addMachineExtruders(global_stack.getBottom(), global_stack.getId())
|
self.addMachineExtruders(global_stack.getBottom(), global_stack.getId())
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def getExtruderValues(name):
|
||||||
|
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||||
|
|
||||||
|
result = []
|
||||||
|
for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()):
|
||||||
|
value = extruder.getRawProperty(name, "value", use_next = False)
|
||||||
|
|
||||||
|
if not value:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if isinstance(value, UM.Settings.SettingFunction):
|
||||||
|
value = value(extruder)
|
||||||
|
|
||||||
|
result.append(value)
|
||||||
|
|
||||||
|
if not result:
|
||||||
|
result.append(global_stack.getProperty(name, "value"))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue