I would like to call an operator everytime I change an Object.
So, like I change a curve, leave the Editmode and now a I want to automatically run an operator.
Maybe I can monitor a mesh and check if something changed.
Or, and I would prefer this, everytime I leave the Editmode on a certain object, the operator is executed.
You want the depsgraph_update handler, which is called whenever data is modified or modes are switched.
You can filter this so it only does whatever on the correct object just by adding an active object check to your function
Sweet, I will check this out! Thanks!
Ok, it works, basicly…
I append a function to bpy.app.handlers.depsgraph_update_post …
But, I still try fo figure out how to check if a function is already there, or how to remove it…
i = 0
for handler in bpy.app.handlers.depsgraph_update_post:
if handler.__name__ == "test_handler_name":
i = i + 1
Ok this this worked
That works, or you can do this:
if test_handler_name in bpy.app.handlers.depsgraph_update_post:
It’s good practice to have a register() and unregister() function in your scripts
Oh, I have, but I am in the middle of… finding the best practices out
This somehow isnt working when I run the script from texteditor… unregister seems to not being called
Oh yeah it won’t work from text editor, I assumed you were making a stand-alone script file. In that case, ignore me and carry on