diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index f0afcef298..579538cb12 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -24,11 +24,11 @@ Item readonly property string infill_mesh_type: "infill_mesh" readonly property string anti_overhang_mesh_type: "anti_overhang_mesh" - property var current_mesh_type: normal_mesh_type + property var current_mesh_type: UM.ActiveTool.properties.getValue("MeshType") function setOverhangsMeshType(){ - if(infillOnlyCheckbox.checked) + if (infillOnlyCheckbox.checked) { setMeshType(infill_mesh_type) } @@ -39,19 +39,13 @@ Item } function setMeshType(type) { - current_mesh_type = type - - // update the active object - if(UM.ActiveTool.properties.getValue("MeshType") !== type) - { - UM.ActiveTool.setProperty("MeshType", type) - } + UM.ActiveTool.setProperty("MeshType", type) // set checked state of mesh type buttons - normalButton.checked = current_mesh_type === normal_mesh_type - supportMeshButton.checked = current_mesh_type === support_mesh_type - overhangMeshButton.checked = current_mesh_type === infill_mesh_type || current_mesh_type === cutting_mesh_type - antiOverhangMeshButton.checked = current_mesh_type === anti_overhang_mesh_type + normalButton.checked = type === normal_mesh_type + supportMeshButton.checked = type === support_mesh_type + overhangMeshButton.checked = type === infill_mesh_type || type === cutting_mesh_type + antiOverhangMeshButton.checked = type === anti_overhang_mesh_type // update active type label for (var button in meshTypeButtons.children) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py index 6998419b9b..0581deb496 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsTool.py @@ -66,7 +66,11 @@ class PerObjectSettingsTool(Tool): selected_object.addDecorator(SettingOverrideDecorator()) selected_object.callDecoration("setActiveExtruder", extruder_stack_id) - def setMeshType(self, mesh_type): + ## Returns True when the mesh_type was changed, False when current mesh_type == mesh_type + def setMeshType(self, mesh_type) -> bool: + if self.getMeshType() == mesh_type: + return False + selected_object = Selection.getSelectedObject(0) stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway. if not stack: @@ -86,6 +90,9 @@ class PerObjectSettingsTool(Tool): new_instance.resetState() # Ensure that the state is not seen as a user state. settings.addInstance(new_instance) + self.propertyChanged.emit() + return True + def getMeshType(self): selected_object = Selection.getSelectedObject(0) stack = selected_object.callDecoration("getStack") #Don't try to get the active extruder since it may be None anyway.