Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   Animating (https://simplymaya.com/forum/showthread.php?t=1877)

Nem 02-11-2002 12:54 PM

Animating
 
what id like a script to do is to aid me in setting keys for animation.
a box will come up which is the actual scripted plugin, and whatever object you click on, it will display the contents of its channel box in this new box, and when you click on the name of one of the attributes, it will key that one attribute instead of you having to go to the channel box, right click and select key selected

are there any scripts like this? if not, how would i go about coding it? cos i dont understand anything about mel

mtmckinley 03-11-2002 04:31 PM

I don't know enough about it to make my own dialogs or anything...

BabyDuck 23-11-2002 11:08 AM

nem, do you still need that script? and what exactly you need help for? you wanna program it yourself? or have working example you can extend? or you want a thing that is ready for use?

let me know what you wish is, as i need to learn mel anyway, and the online manual is rather good compared to other programming languages i seen so far. when you want the script that is complete and ready, then dont be surprised if i make only real short names in it, so you have checkboxes named TX, TY, TZ, RX,RY,RZ,SX,SY,SZ... - for translate rotate and scale - so ALL attributes that can be keyed fit in a dialog box. but one thing, give me time to program that :D

Nem 23-11-2002 12:29 PM

yeah i still do need that script, i have nothing on it because i dont understand anything about mel, was wondering if there was a pre-existing script for it, but there isnt :(
sorry, i have no idea what u mean :confused: and im not lookin for checkboxes, just clickable things

BabyDuck 23-11-2002 12:56 PM

Quote:

Originally posted by Nem
sorry, i have no idea what u mean :confused: and im not lookin for checkboxes, just clickable things
ok, this is what i plan to do for you:

one mel scripts: a window pops up, and there are all attributes that could be keyable looking like:
[x] TX [x] TY [x] TZ [ ] RX [ ] RY [ ] RZ .....

meaning that if you hit the key button also in this window you can set a key for tx, ty, tz, but not rx ry rz (for transtlate, but not rotate).

next time you want to key anything you ned not open the window and change settings, but just hit the "g" key to apply the keys to another selection or at another time.

what i really would like to have, is bind the window to a keydown, meaning if you press the key down and hold, the window pops up and you can alter the settings, and if you release then it makes the keys. so it is one button thing for all - and if you are satisfied with the selection, when you just have to hit the key and release at once and it makes the changes.

hope that is clear now ... :rolleyes:

Nem 23-11-2002 01:08 PM

that is kinda what i want, but i think its a tad bit more complex than that :S

basically:

you have objects in your scene, and you pick and object, go to the channel box and thats where you set keys normally right?

well for this, i want it so, you run the mel script and a window pops up, you select an object and that mel script windows *automatically* refeshes and it shows a list of that particular object's channels (like you said above with ur lovely diagram) but these channels in the script window wouldnt just be translate scale and rotate, it would include custom attributes as well (id say this is the most important part).
the last thing is, instead of having checkboxes, id like to have each attribute (eg. rotate y) onto a clickable box, and when that box is clicked, that one attribute is keyed, so you can just click names and keys would be set for the names you clicked (simpler than checkboxes :))
and then you deselect the object and the mel script window shows nothing inside it, you select another object and the mel script window would refresh showing all the channels/attributes of that new object

so its all about automation really
sorry if im being so totalyl awkward, cos i no i am :D

adldesigner 23-11-2002 01:19 PM

Hmm, that would be actually a quite handy script.
Maybe there´s a getAttribute command or something that would prove successfull don´t you think?
<-- doesn´t have the slighlest clue about programming.

Nem 23-11-2002 01:24 PM

handyness is the key to productivity :) im just not productive enough to make it myself cos i dnt no how to do it :(

BabyDuck 23-11-2002 02:16 PM

ok ok, now we come somewhere. you want a window, that is constantly open like AE, but it shows all keyable things with buttons (not only the rotate and scale, i thought my "..." where clear to include all, but did not want to write all down here just making example that due to place reasons in the window there will be no "translate x" but "tx" - and no "selection handle" but "sh")

and the buttons are orange if the key is set and if you push the button, it deletes the key and button becomes grey and if you push again you set the key and button becomes orange.

that can be done even easier than the tool i wanted to create - but i suggest a button that updates the state of the window - as constant update whenever you change your selection might kill performance if you have the window open always. another drawback - if only some of the selection has a key, then it say, that RX is keyed, even if not all selected things have keys there - but if you want to be sure that the whole selection has the same keys set, you could just click a attribute twice (first unsetting all keys that were set, and then setting every keys for all objects in selection).

edit: oh right i just reread - and you wanted the update automatically - i will try to do that - must be possible somehow :d

kbrown 23-11-2002 02:36 PM

BabyDuck: Just a little warning. UI creation and management isn't an easy thing to do with mel. It's pretty strange if you ask me. So go light on the UI first and make sure you understand what you've done before going for any dynamic stuff.

BabyDuck 23-11-2002 02:41 PM

Quote:

Originally posted by kbrown
BabyDuck: Just a little warning. UI creation and management isn't an easy thing to do with mel. It's pretty strange if you ask me. So go light on the UI first and make sure you understand what you've done before going for any dynamic stuff.
UI shall be hard to do? nope it is easy. you just make a window, put some buttons and assign what you want them to do.

believe me, there are languages where UI is damn hard to implement, mel is real easy to work with :)

adldesigner 23-11-2002 02:46 PM

Quote:

Originally posted by BabyDuck
UI shall be hard to do? nope it is easy. you just make a window, put some buttons and assign what you want them to do.

believe me, there are languages where UI is damn hard to implement, mel is real easy to work with :)

Hey BabyDuck ... Lol ... that´s the K-man talking. If he says its a bit strange it is. LOL :)

By the way, K ... any way that the references planes' script could be customized into inserting more reference planes? for example bottom ... or the other sides? that would complement it very well .. I´m creating a button for it. Perhaps you could include it in your zip file :)

kbrown 23-11-2002 02:53 PM

Quote:

Originally posted by adldesigner

By the way, K ... any way that the references planes' script could be customized into inserting more reference planes? for example bottom ... or the other sides? that would complement it very well .. I´m creating a button for it. Perhaps you could include it in your zip file :)

They would be easy to implement. I'll take a note of this, but first there are some other issues I have to conquer first...

adldesigner 23-11-2002 03:03 PM

Quote:

Originally posted by kbrown
They would be easy to implement. I'll take a note of this, but first there are some other issues I have to conquer first...
Right on bud! :beer:

Nem 23-11-2002 03:18 PM

ooh lots of complicated mel talk :confused:
babyduck: you know you said you could make it so when you click a button in the mel box and it keys (turns it orange in the channel box) and when you click again it deletes the key? mayb when you scrub the time slider, and it reaches a point where the object's attribute already has a keyframe, then in the mel window, that attribute would be yellow as well, just so the user knows if there already is a keyframe, cos otherwise you could go around deleting all the keyframes you have when all you want to do is SET them
or
what about in the script box, you have 2 buttons for each attribute in the channel box? one for key, one for delete key? but i spose it wud still have to turnorange for you to no if there already is a key or not

*EDIT*: just had a thought, would it be easier, animation wise, to have a slider in the mel script box as well? cos then you could do all animation in the new window and key it really fast as well without having to go into ur viewport or channel box
there shud also be a button at the bottom which says "Key All" hmm, wonder what that would do :)

kbrown 23-11-2002 03:58 PM

Quote:

Originally posted by BabyDuck
UI shall be hard to do? nope it is easy. you just make a window, put some buttons and assign what you want them to do.

believe me, there are languages where UI is damn hard to implement, mel is real easy to work with :)

Yeah, the UI with MEL is easy to do if you keep it simple. That's what I meant. Nothing else...

BabyDuck 23-11-2002 04:28 PM

Quote:

Originally posted by Nem
ooh lots of complicated mel talk :confused:
babyduck: ...
no. i mean, the key that gets deleted is only in the time right now - i am not planning delete keys that are in other time. what i tried to explain is, if there is a key set to translateX right now in at least one part of a multiple selection, then it indicates that it is set. and 3 things per attribute would be ok too, so 2 buttons to set and cut the key, and one field indicating if some or none of the objects are keyed right now.

Quote:

*EDIT*: just had a thought, would it be easier, animation wise, to have a slider in the mel script box as well? cos then you could do all animation in the new window and key it really fast as well without having to go into ur viewport or channel box
there shud also be a button at the bottom which says "Key All" hmm, wonder what that would do :)
i dont think that would be a brilliant idea - if you dont leave the key window, nothing gets manipulated, and the animation would not do anything at all. if you animate you have to go to next time you want to set a key, manipulate your object via move, skale, whatever - and then set a key for whatever you changed ...

Nem 23-11-2002 04:33 PM

oh right, i get ya
so how shud this thing be started?

BabyDuck 23-11-2002 04:53 PM

i am working on good looks right now, but i decided to use a iconTextCheckbox, as you can assign different command if you push it in and out.

the dynamic update will be done later - if you only want to see it how i will do it for one single keyable thing, i can put that mel down ...

Nem 23-11-2002 04:58 PM

oh right, thought i was gunna do it...phew :D
thanks babyduck
but i do want to learn this stuff :) just not atm
what does the iconTextCheckbox function do?

BabyDuck 23-11-2002 05:14 PM

Quote:

Originally posted by Nem
oh right, thought i was gunna do it...phew :D
thanks babyduck
but i do want to learn this stuff :) just not atm
what does the iconTextCheckbox function do?

ok here it is, works fine, but it is not aware what state it is right now if you press the TX once, it will set the key for translate x for the whole selection. and the button turns red. when you press again, it will delete the key of whole selection and turn the button white. the iconTextCheckBox has 2 functions that are executed when i change the state of it (the onc and ofc, or on long onCommand, offCommand). you can copy that and try it out - not great yet, but this it what the thing will be:

Code:

string $window = `window`;

    columnLayout;

    string $txb = `iconTextCheckBox -style "textOnly" -h 20 -label "TX" -ann "translate X"`;

    iconTextCheckBox -e -onc {"setKeyframe -at tx; iconTextCheckBox -e -bgc 0.5 0.2 0.0 "+$txb+";"} $txb;

    iconTextCheckBox -e -ofc {"cutKey -at tx; iconTextCheckBox -e -bgc 1.0 1.0 1.0 "+$txb+";"} $txb;

    showWindow $window;

(hope this forum supports the code keyword :D )

BabyDuck 23-11-2002 05:20 PM

oh no, not fully tested, cutKey completely removes the key everywhere :D - so it needs to be changed :D

Nem 23-11-2002 05:21 PM

oooooh wow, how cool! im liking it :D first time ive bin excited in a long time!

i get a
Error: Invalid flag: -bgc
when i hit TX

what wud happen if a custom attribute had a longer name?
oh ive noticed that if you open up the window for one object, and while that window is still open and u try it wiv another window, the size gets smaller

BabyDuck 23-11-2002 05:46 PM

dang, i tested it - and i found the problem so only the current keyframe gets cut out, but it should find the bgc.

Code:

string $window = `window`;
    columnLayout;
    string $txb = `iconTextCheckBox -style "textOnly" -h 20 -label "TX" -ann "translate X"`;
    iconTextCheckBox -e -onc {"setKeyframe -at tx; iconTextCheckBox -e -backgroundColor 0.5 0.2 0.0 "+$txb+";"} $txb;
    iconTextCheckBox -e -ofc {"cutKey -at tx -t `currentTime -q`; iconTextCheckBox -e -backgroundColor  1.0 1.0 1.0 "+$txb+";"} $txb;
    showWindow $window;

and it is far from useable now. i am not sure, in the bgc it says "windows only flag" does that mean only winNT will like that???

Nem 23-11-2002 05:51 PM

well thats madness cos im on an NT based system, how weird
its working :) just tried a lil ball anim, and it works :)
but when i try it i only see one clickable box, and thats TX, the others dont appear for some reason

BabyDuck 23-11-2002 06:13 PM

here is a bit better version - made them all buttons and included more than tx - now ty is there as well :D ...

Code:

window -t "TX and TY";
    rowColumnLayout -numberOfColumns 3;
    string $TXButtonSet = `button -l "setTX"`;
        //pressing this button will set a key for translateX
    button -e -c {"setKeyframe -at tx;"} $TXButtonSet;
    string $TXButtonCut = `button -l "cutTX"`;
        //pressing this button will delete key for translateX right now
    button -e -c {"cutKey -t `currentTime -q` -at tx ;"} $TXButtonCut;
    string $TXButtonCutAll = `button -l "cutAllTX"`;
        //pressing this button will delete key for translateX everywhere
    button -e -c {"cutKey -at tx;"} $TXButtonCutAll; 
        //same for ty
    string $TYButtonSet = `button -l "setTY"`;
    button -e -c {"setKeyframe -at ty;"} $TYButtonSet;
    string $TYButtonCut = `button -l "cutTY"`;
    button -e -c {"cutKey -t `currentTime -q` -at ty;"} $TYButtonCut;
    string $TYButtonCutAll = `button -l "cutAllTY"`;
    button -e -c {"cutKey -at ty;"} $TYButtonCutAll;
showWindow;


BabyDuck 23-11-2002 06:15 PM

but the indicator if you have keys for something atm is driving me nuts - maybe you are satisfied with the last version (of course more attributes needs be added :D)

BabyDuck 24-11-2002 10:37 AM

working now
 
ok, the script is working: you can set keys and cut keys (now or in whole scene) of ALL keyable attributes. the indicator is still missing if a key is set already or not. and whenever you change the selected objects you have to run the script again, as only that will ensure that all attributes (the custom ones too) will show correctly. the easiest way to use it, is to copy the whole code (be sure you got all) into script editor, there select all, and mmb-drag it to the shelf - a MEL button that runs the setkey will appear ;)

enjoy

p.s.: no comments in code, no docu? i know, dont blame me, it is my first mel try :D


Code:

string $setKeyKeyable;
if (`window -exists $setKeyKeyable`) deleteUI -window $setKeyKeyable;
$setKeyKeyable = `window -wh 450 400 -t "Set Key Keyable"`;
    rowColumnLayout -numberOfColumns 4;
    string $setB,$cutB,$cutAllB,$attr;
    string $attrList[] = `listAttr -k`;
    if( size($attrList) > 0){
      $attrList = stringArrayRemoveDuplicates($attrList);
      $attrList = sort ($attrList);
      for( $i=0; $i<size($attrList); $i+=1 ) {
          $attr = $attrList[$i];
          text -label $attr -align "center"; $setB = `button -l "set"`;
          $cutB = `button -l "cut"`;
          $cutAllB = `button -l "cutAll"`;
          button -e -c {"setKeyframe -at "+$attr+";"} $setB;
          button -e -c {"cutKey -t `currentTime -q` -at "+$attr+";"} $cutB;
          button -e -c {"cutKey -at "+$attr+";"} $cutAllB;
      }
    } else
      text -label "no keyable";
  setParent ..;
showWindow $setKeyKeyable;


Nem 24-11-2002 08:56 PM

i keep gettin a syntax error, even when i type it out :(

BabyDuck 24-11-2002 10:09 PM

sorry about that nem.

can please anyone else confirm this? i can copy and paste it in script editor from here without problem :argue:

BabyDuck 24-11-2002 10:15 PM

1 Attachment(s)
ok, nem try this.

i attached a mel file. copy it to my prefs/maya/scripts and then use this command in script editor or command line:
Code:

source bd_setkey;
hope you only made the wrong selection.

edit: i just downloaded it myself and tried it, and it works fine with my computer (maya 4.5 unlimited, 1.33 ghz TB, 768 mb ram, gf2mx400 running as quadro 2). did i use any stuff that would not work with other maya versions???? :banghead:

Nem 25-11-2002 04:29 PM

oK that works :) i think ill make some adjustments to the code, like change the name, window size etc thats assumin ill get any mel help read

BabyDuck 25-11-2002 06:40 PM

Quote:

Originally posted by Nem
oK that works :) i think ill make some adjustments to the code, like change the name, window size etc thats assumin ill get any mel help read
do whatever you want on the file, if you want a better docu, i can deliver, but only if there is need ;)

Nem 25-11-2002 06:43 PM

how do you change the name of the script file? like atm you have to type
source bd_setkey

how do i make it so i just type in setkey into the command line?

adldesigner 25-11-2002 06:54 PM

Quote:

Originally posted by Nem
how do you change the name of the script file? like atm you have to type
source bd_setkey

how do i make it so i just type in setkey into the command line?

Nem .. do you know what BD means?
Means BabyDuck so I´d expect you to respect the guy´s credit after he´s helped you that much.

Nem 25-11-2002 06:57 PM

oh right, thought it was some weird mel call function or whatever theyre called


All times are GMT. The time now is 03:14 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018