CURA-4400 fix support_extruder_nr values in overhang angle and SliceInfo

This commit is contained in:
Jack Ha 2018-03-19 10:56:40 +01:00
parent f407663508
commit bd775cf32e
4 changed files with 13 additions and 5 deletions

View file

@ -41,7 +41,7 @@ class CuraSceneNode(SceneNode):
# Use the support extruder instead of the active extruder if this is a support_mesh # Use the support extruder instead of the active extruder if this is a support_mesh
if per_mesh_stack: if per_mesh_stack:
if per_mesh_stack.getProperty("support_mesh", "value"): if per_mesh_stack.getProperty("support_mesh", "value"):
return extruders[int(global_container_stack.getProperty("support_extruder_nr", "value"))] return extruders[int(global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))]
# It's only set if you explicitly choose an extruder # It's only set if you explicitly choose an extruder
extruder_id = self.callDecoration("getActiveExtruder") extruder_id = self.callDecoration("getActiveExtruder")

View file

@ -8,6 +8,7 @@ from typing import Any, Optional
from PyQt5.QtCore import pyqtProperty, pyqtSignal, QObject from PyQt5.QtCore import pyqtProperty, pyqtSignal, QObject
from UM.FlameProfiler import pyqtSlot from UM.FlameProfiler import pyqtSlot
from UM.Application import Application
from UM.Decorators import override from UM.Decorators import override
from UM.Logger import Logger from UM.Logger import Logger
from UM.Settings.ContainerStack import ContainerStack, InvalidContainerStackError from UM.Settings.ContainerStack import ContainerStack, InvalidContainerStackError
@ -314,6 +315,13 @@ class CuraContainerStack(ContainerStack):
return cls._findInstanceContainerDefinitionId(definitions[0]) return cls._findInstanceContainerDefinitionId(definitions[0])
## getProperty for extruder positions, with translation from -1 to default extruder number
def getExtruderPositionValueWithDefault(self, key):
value = self.getProperty(key, "value")
if value == -1:
value = int(Application.getInstance().getMachineManager().defaultExtruderPosition)
return value
## private: ## private:
# Private helper class to keep track of container positions and their types. # Private helper class to keep track of container positions and their types.

View file

@ -146,7 +146,7 @@ class SliceInfo(Extension):
model_stack = node.callDecoration("getStack") model_stack = node.callDecoration("getStack")
if model_stack: if model_stack:
model_settings["support_enabled"] = model_stack.getProperty("support_enable", "value") model_settings["support_enabled"] = model_stack.getProperty("support_enable", "value")
model_settings["support_extruder_nr"] = int(model_stack.getProperty("support_extruder_nr", "value")) model_settings["support_extruder_nr"] = int(model_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))
# Mesh modifiers; # Mesh modifiers;
model_settings["infill_mesh"] = model_stack.getProperty("infill_mesh", "value") model_settings["infill_mesh"] = model_stack.getProperty("infill_mesh", "value")
@ -177,7 +177,7 @@ class SliceInfo(Extension):
# Support settings # Support settings
print_settings["support_enabled"] = global_container_stack.getProperty("support_enable", "value") print_settings["support_enabled"] = global_container_stack.getProperty("support_enable", "value")
print_settings["support_extruder_nr"] = int(global_container_stack.getProperty("support_extruder_nr", "value")) print_settings["support_extruder_nr"] = int(global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))
# Platform adhesion settings # Platform adhesion settings
print_settings["adhesion_type"] = global_container_stack.getProperty("adhesion_type", "value") print_settings["adhesion_type"] = global_container_stack.getProperty("adhesion_type", "value")

View file

@ -62,7 +62,7 @@ class SolidView(View):
global_container_stack = Application.getInstance().getGlobalContainerStack() global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack: if global_container_stack:
support_extruder_nr = global_container_stack.getProperty("support_extruder_nr", "value") support_extruder_nr = global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr")
support_angle_stack = Application.getInstance().getExtruderManager().getExtruderStack(support_extruder_nr) support_angle_stack = Application.getInstance().getExtruderManager().getExtruderStack(support_extruder_nr)
if support_angle_stack is not None and Preferences.getInstance().getValue("view/show_overhang"): if support_angle_stack is not None and Preferences.getInstance().getValue("view/show_overhang"):
@ -89,7 +89,7 @@ class SolidView(View):
# Use the support extruder instead of the active extruder if this is a support_mesh # Use the support extruder instead of the active extruder if this is a support_mesh
if per_mesh_stack: if per_mesh_stack:
if per_mesh_stack.getProperty("support_mesh", "value"): if per_mesh_stack.getProperty("support_mesh", "value"):
extruder_index = int(global_container_stack.getProperty("support_extruder_nr", "value")) extruder_index = int(global_container_stack.getExtruderPositionValueWithDefault("support_extruder_nr"))
try: try:
material_color = self._extruders_model.getItem(extruder_index)["color"] material_color = self._extruders_model.getItem(extruder_index)["color"]