1
$\begingroup$

I try to execute update on my custom pynodes when user performs action: delete links, add link, removes node. From Animation Nodes or Sverchok I could figure out i can use NodeTree -> update() method to execute changes (way better than using scene_update_post handlers, because it fires only on events performed on node tree). Is there way to get what kind of element user removed/created (link, node) from that update() method? So that I can execute update on affected nodes?

Example of my problem below (Alpha Channel wont get updated on socket connect event): Alpha Channel wont get updated on socket connect event For now I'm thinking of creating global cache_links, that will contain previous state of all links in node tree. From that I could possibly compare what link got added/erased on update() event. And then do node updates on affected links from_nodes and to_nodes...

$\endgroup$
  • 1
    $\begingroup$ You probably already figured it out, but all you need to do is to declare an update(self) function in your node class. Blender will call it automatically when nodes connected or disconnected. $\endgroup$ – VSB Nov 30 '18 at 13:01
  • 1
    $\begingroup$ Thanks @VSB, I haven't figured this out myself. I will test this when I will have more time. $\endgroup$ – JoseConseco Dec 1 '18 at 20:18
  • $\begingroup$ I used the update() function, but the problem was (in blender 2.79) that it would cause whole node tree to update, even if given node was not affected directly by connected/disconnected node. But the good new is, it update() is not required in blender 2.8. Node affected by socket connection, is updated properly. $\endgroup$ – JoseConseco Jan 30 at 18:02
  • $\begingroup$ Hmmm that is interesting about 2.8 I did not know that. The way I have it working in 2.79 is checking if the node data needs to be recomputed and of it doesn't I just skip over it, but I might have to change this behavior a bit for 2.8 $\endgroup$ – VSB Jan 30 at 18:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.