hello everybody: In mel script, i used the intSliderGrp. If i pull/drag the slider, the value changed. and i want to make the model do the motion according to the changing value in real time. (e.g. the motion is rotation, so the skeleton can rotate in real time,just like use rotation control).
what mel's event trigger/attributeChange function can make it? or other functions please give me a simple example to show how to use the function.
There are several ways to do this: 1. you can evalutate a command on change/drag of your slider. See dragCommand or changeCommand in its docs. If you do so: there is a very handy shortcut for the elements value:
CODE intSliderGrp -dragCommand "myProcToEval #1"; here the #1 automatically passes the value thats set in the control to your command. (Its the same as intSliderGrp -dragCommand "myProcToEval (intSliderGrp -query -value myIntSliderGrp)" myIntSliderGrp; but of course shorter and more flexible! Because you dont have to give it a name)
2. you can put a sriptJob under your UI to control a specific attribute. See the scriptJob docs as well. CODE sriptJob -parent myUI -attributeChange myObject.myAttribute myProcToEval;
3. create a attrControlGrp / attrFieldSliderGrp / attrFieldGrp for your attribute. This is actually the most sophisticated approach! Because this control does everything you need considering setting and getting. Unless... yea. If you want to control multiple attributes.. you have to combine stuff. If you want a different sliding scale at the control.. use option 1. and change all attrs in your fired proc.
QUOTE(ewerybody @ 11/13/07, 12:45 PM) [snapback]276419[/snapback] [b]3.[/b] create a attrControlGrp / attrFieldSliderGrp / attrFieldGrp for your attribute. This is actually the most sophisticated approach! Because this control does everything you need considering setting and getting. Unless... yea. If you want to control multiple attributes..
3 is the proper way, because it actually slaves the attribute to a node into the dg directly. Api knows a bit fo mumbojumbo about theese kinds of stuff and thwy are called contexts wich in most cases ares ortof temporary nodes.
Now maya performance wise its actually sane to only drive one attribute and then let that attribute drive all the new ones by temporary connection. So no matter if you want to drive many 3 still works.
both scriptjibs and change commands are horrible to your undoqueue
Would be nice for them to actually implementa bit broader spectrum linkages like this. The connectConrol is halfway deecent
QUOTE(ewerybody @ 11/13/07, 02:45 AM) [snapback]276419[/snapback] There are several ways to do this: 1. you can evalutate a command on change/drag of your slider. See dragCommand or changeCommand in its docs. If you do so: there is a very handy shortcut for the elements value: CODE intSliderGrp -dragCommand "myProcToEval #1"; here the #1 automatically passes the value thats set in the control to your command. (Its the same as intSliderGrp -dragCommand "myProcToEval (intSliderGrp -query -value myIntSliderGrp)" myIntSliderGrp; but of course shorter and more flexible! Because you dont have to give it a name)
2. you can put a sriptJob under your UI to control a specific attribute. See the scriptJob docs as well. CODE sriptJob -parent myUI -attributeChange myObject.myAttribute myProcToEval;
3. create a attrControlGrp / attrFieldSliderGrp / attrFieldGrp for your attribute. This is actually the most sophisticated approach! Because this control does everything you need considering setting and getting. Unless... yea. If you want to control multiple attributes.. you have to combine stuff. If you want a different sliding scale at the control.. use option 1. and change all attrs in your fired proc.
whoar cool! I didn't know about connectControl until now! Now Thats some cool news!!!
But again no multi connection from one field. And THATS what I'm actually looking for!! And why I will have to stick to dragCommand and scriptJobs
But good to know though. Now I can setup a control and connect it to an attr! Instead of creating fire-and-forget-style attrControlGrp and then guessing what control Type it is to make it fit into the layout...
QUOTE(ewerybody @ 11/13/07, 10:03 PM) [snapback]276447[/snapback] But again no multi connection from one field. And THATS what I'm actually looking for!! And why I will have to stick to dragCommand and scriptJobs
you can create a scriptjob that resides as long as your window does and make a node that connects and does the updating.
QUOTE(Joojaa @ 11/13/07, 01:16 PM) [snapback]276454[/snapback] huh you can create a scriptjob that resides as long as your window does and make a node that connects and does the updating.
thank you two guys,
and you still discuss the control problem. is that my original problem?
QUOTE(Joojaa @ 11/14/07, 09:18 AM) [snapback]276475[/snapback] no i duisuss the spirit of how maya assumes you solve problems.
hoho . But..: "make a node that connects and does the updating." You mean when I create a node that is connected from my initial value to all potential other attributes the undo problem is solved?
Nice but what if someone saves the scene, cvs checks it in and closes the UI afterwards.. someone else opens up the scene and those attributes are still connected. I actually don't want any extra crap to remain in the scene.
The ideal solution would be if one could really connect one UIcontrol to multiple attributes!