UltiMaker uses functional, analytical and tracking cookies. Tracking cookies enhance your experience on our website and may also collect your personal data outside of Ultimaker websites. If you agree with the use of tracking cookies, click “I agree, continue browsing”. You can withdraw your consent at any time. If you do not consent with the use of tracking cookies, click “Refuse”. You can find more information about cookies on our Privacy and Cookie Policy page.
Plugin help: How to detect when print setting change?
Posted
(edited)
· Plugin help: How to detect when print setting change?
I think you are looking for the "propertyChanged" signal of the "global stack". To connect to it, you first need to connect to the "globalContainerChanged" signal of the machine manager. So something like this (untested code, there may be typos):
def __init__(self, parent: Optional[QObject] = None) -> None:
(...)
self._global_stack = None # type: Optional[GlobalStack]
machine_manager = cura.CuraApplication.CuraApplication.getInstance().getMachineManager()
# Reconnect all signals when the active machine gets changed.
machine_manager.globalContainerChanged.connect(self._onMachineChanged)
(...)
def _onMachineChanged(self) -> None:
if self._global_stack:
self._global_stack.propertyChanged.disconnect(self._onPropertyValueChanged)
self._global_stack = self._machine_manager.activeMachine
if self._global_stack:
self._global_stack.propertyChanged.connect(self._onPropertyValueChanged)
def _onPropertyValueChanged(self, key: str, property_name: str) -> None:
if key == "layer_height":
Logger.log("d", "Layer Height changed")
Posted
· Plugin help: How to detect when print setting change?
Thank you! I sort of found the right callback, but had to do some work-arounds because I didn't know about the need to connect to the globalContainerChanged callback.
Thank you for taking the time to explain that. This is exactly what I needed.
2
Link to post
Share on other sites
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
In the Cura 5.8 stable release, everyone can now tune their Z seams to look better than ever. Method series users get access to new material profiles, and the base Method model now has a printer profile, meaning the whole Method series is now supported in Cura!
We are happy to announce the next evolution in the UltiMaker 3D printer lineup: the UltiMaker Factor 4 industrial-grade 3D printer, designed to take manufacturing to new levels of efficiency and reliability. Factor 4 is an end-to-end 3D printing solution for light industrial applications
Recommended Posts
ahoeben 1,981
I think you are looking for the "propertyChanged" signal of the "global stack". To connect to it, you first need to connect to the "globalContainerChanged" signal of the machine manager. So something like this (untested code, there may be typos):
def __init__(self, parent: Optional[QObject] = None) -> None: (...) self._global_stack = None # type: Optional[GlobalStack] machine_manager = cura.CuraApplication.CuraApplication.getInstance().getMachineManager() # Reconnect all signals when the active machine gets changed. machine_manager.globalContainerChanged.connect(self._onMachineChanged) (...) def _onMachineChanged(self) -> None: if self._global_stack: self._global_stack.propertyChanged.disconnect(self._onPropertyValueChanged) self._global_stack = self._machine_manager.activeMachine if self._global_stack: self._global_stack.propertyChanged.connect(self._onPropertyValueChanged) def _onPropertyValueChanged(self, key: str, property_name: str) -> None: if key == "layer_height": Logger.log("d", "Layer Height changed")
Link to post
Share on other sites
bradk3 14
Thank you! I sort of found the right callback, but had to do some work-arounds because I didn't know about the need to connect to the globalContainerChanged callback.
Thank you for taking the time to explain that. This is exactly what I needed.
Link to post
Share on other sites