PDA

View Full Version : bi-directional affectsAttribute


linfa
02-17-2011, 01:27 PM
Hi there,
this is my very first thread here. I found plenty of answers on this forum, already, but now I'm stuck with something I really can't figure out.
I couldn't find any ultimate solution to my issue, among threads dealing with similar ones, but please just re-address me to any one which I might have missed.

What I want to get is the following.
For 2 attributes "A" and "B" within a custom MPXLocatorNode "myNode", I'd want them to behave as Maya cameraShape's Angle of View and Focal Length atrributes. That is (let's say A is Focal Length; B is Angle of View):

A is keyable. B is not.
When A or B is modified, the other one changes accordingly. I noticed that A must be the "main" attribute, between the two: while changing A using its slider, B's slider move accordingly, in real-time. Instead, when modifying B with its slider, both A's value field and slider only update when the mouse is released.
Then, I guess the keyable attribute is to be the "main", guiding one (and it is logical indeed).


In my case, what I did is:

A is keyable. B is not.
A affects B, B affects A.
The above were set within the initialize() function.
I have cases implemented for both A and B, in an exactly symmetrical way, within setDependentsDirty() and compute().
Also, within the compute(), I setClean() both A and B, in any case.

As far as I could get until now:
- when I change A's value, I see B updated within the AE in real time, and I see from the output window that the compute() is properly called.
- when, instead, I change B's value, A doesn't update and compute() is not called. If I then call getAttr myNode.A with MEL, then the compute() is properly called and the returned value is correct, but still the AE isn't refreshed. If, after that, I select any other object in the outliner and then select back myNodeShape, only at that time I can see the AE refreshed with the current, correct values.

So, my question splits in two:

1) How do I force the compute() for keyable attribute A?
2) How do I get the AE refreshed after compute() is called?

I hope I was clear enough, and that my question wasn't too dumb (I'm definitely a noob with Maya's API).

Thank you all in advance,
s

linfa
03-01-2011, 07:31 PM
Since a few days have passed from my request, and no answer was given, I would ask if any of you can give me some feedback, at least:
weren't the question and scenario clear enough?
is my intent actually too hard to achieve?
am I asking for something too dumb?

Thank you all,
s

Robert Bateman
03-04-2011, 01:10 AM
1) you cant.
2) a scriptjob (or MMessage) watching for attribute changes.

CGTalk Moderation
03-04-2011, 01:10 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.