0

I have a custom node that uses cmds.setAttr() from within its compute function to update the attributes of two nodes that are connected to it (the purpose of the node is to sync two attribute without locking them). The node works as expected, syncing the values between a single ramp node color entry position and the translate of a pCube (ramp position is a single double which is converted to three doubles for the translate and vice versa).

The ramp node is mapped to a plane in the viewport. When I change the position of the ramp color entry in the attribute editor, the viewport shading updates as expected, and the pCube moves to the appropriate position. However, when I move the cube, the ramp position and thumbnail preview update properly in the AE, but the viewport shading on the plane does not update.

I know that this is happens because the outColor of the ramp does not change when the position the color entry is set with the command, so I would assume that I should be able to either set the outColor plug dirty or set the ramp entry position plug dirty since the outColor should be dependent on it. The problem is that when I try to do this from within the compute function using the maya.dgdirty() command, the viewport still does not update (and as fart as I can tell, the attribute is not reevaluated).

Strangely, when I use the same maya.dgdirty() command from the script editor, it causes the viewport to update as expected. Essentially, my question is: how can I get the outColor of ramp node to properly update (and thus cause the viewport shading to update) after the ramp entry postion has been set within my sync node's compute function?

  • You might want to look at [this question](https://stackoverflow.com/questions/44021794/how-to-get-data-from-an-upstream-node-in-maya/44053969#44053969) for some context. Using SetAttr inside compute breaks the theoretical structure of the DAG graph -- you're not getting updates because you're going around the flow of information implied by the node network , which Maya knows and uses to handle the updates. – theodox Jun 30 '17 at 05:36
  • Yes, I understand that what I am trying to do does rub up against the way that a DAG is supposed to be used. However, to the best of my knowledge, it would be impossible to create a mapping between two different attributes on different nodes and sync them without going against that structure (I do realize this can be done with script jobs and just avoiding the DAG, but I want to use nodes because they allow for smoother feedback and have better performance). If I am careful, I should be able to dirty things manually, but Maya's mechanisms for this are mysterious and don't work as advertised. – SnippedPaws Jun 30 '17 at 16:32
  • You may have better luck with parallel dag evaluation turned off... but it's always going to be dicey if I understand the setup correctly. – theodox Jul 01 '17 at 06:38

0 Answers0