Hmm… you could save a temporary list of all the nodes in the graph; should be a simple “for z in y” deal, and compare that with the current nodes on depsgraph_update. If they’re different, do something, otherwise, do nothing
This is an idea…
Or maybe just memo the nodes count
This should be cheaper from a CPU point of view.
But…
I need the handler to be called when user changes for example a value in nodes editor…
Isn’t there a way in blender to detect the window or the area the mouse pointer is over ?
There is indeed, as it is used when you open/close an N panel… but is it ‘catchable’ ?
You can filter ID types that were tagged during a depsgraph update.
See id_type_updated for a list of possible ID type string enums.
import bpy
def on_nodetree_change(scene, depsgraph):
if depsgraph.id_type_updated("NODETREE"):
print("Node tree updated")
bpy.app.handlers.depsgraph_update_post.append(on_nodetree_change)
Calling id_type_updated is cheap. It just tests a byte array against zero.
In the above example _post is used. You can also use the _pre handler, but note that the depsgraph argument in the _pre handler will be None when the callback is called.
I had no idea of how to dig in depsgraph data and get what i needed in it. The strange thing is that the handler i used ( took from an example on the web ) did not have the depsgraph parameter. I only had the scene one and didn’t know how to deal with it.
My obvious lack of blender internals often blocks me and most of the time the blender API online doc is of no help to me. Is there somewhere on the web a ‘from surface-to-depth’ documentation on what blender API offers with generic but complete examples ( just like the unity3D online doc ) ?
Thanks you very very much ! And have a great day !