Browse Source

For a per-object setting, use the user-defined value first

CURA-4186

In a per-object setting, if there is user defined value, use that first.
If the value is default, then evaluate it with the normal routine.
Lipu Fei 7 years ago
parent
commit
a320784a6d
1 changed files with 8 additions and 0 deletions
  1. 8 0
      cura/Settings/PerObjectContainerStack.py

+ 8 - 0
cura/Settings/PerObjectContainerStack.py

@@ -3,6 +3,7 @@ from typing import Any, Optional
 from UM.Decorators import override
 from UM.Settings.Interfaces import PropertyEvaluationContext
 from UM.Settings.ContainerStack import ContainerStack
+from UM.Settings.SettingInstance import InstanceState
 
 
 class PerObjectContainerStack(ContainerStack):
@@ -17,6 +18,13 @@ class PerObjectContainerStack(ContainerStack):
         from cura.CuraApplication import CuraApplication
         global_stack = CuraApplication.getInstance().getGlobalContainerStack()
 
+        # Return the user defined value if present, otherwise, evaluate the value according to the default routine.
+        if self.getContainer(0).hasProperty(key, property_name):
+            if self.getContainer(0)._instances[key].state == InstanceState.User:
+                result = super().getProperty(key, property_name, context)
+                context.popContainer()
+                return result
+
         # Handle the "limit_to_extruder" property.
         limit_to_extruder = super().getProperty(key, "limit_to_extruder", context)
         if limit_to_extruder is not None: