Hi there all, Im creating a scripted node in with python and one of the attributes is a messageAttr witch i want to show in the AE ad an option menu of a list of maya cameras, so far i have this (amongts many otehr things) in the AE...template
global proc AE\_custom\_camera\_menu(string $attr){
rowLayout -nc 3;
text -label "Camera"
optionMenu -width 200;
string $str[] = `ls -cameras`;
int $i;
for ($i = `size($str)`; $i > 0; $i--){
menuItem -label $str[$i-1];
}
}
so this populates the list just fine but i cant figure out or find any documentation on how to update the contents of the optio menu. Presumably i would want to create some sort of procedure that gets called when the menu is clicked, but even if i could figure out how to make the procedure get triggered i woudlnt know how to access the option menu usually i would assign it to a global variable but thats out of the question as i may have many instances of the node in my scene, any ideas how I'd do this?
Well allmost certainly do not want the first and the second procedure the same. At minimum you want the second call custom argument be calling the first after a global reset of the guitem.
so this populates the list just fine but i cant figure out or find any documentation on how to update the contents of the optio menu.
that would be the job of the second callcustom argument.
Presumably i would want to create some sort of procedure that gets called when the menu is clicked,
No don't do that you dont need it. Update the menu when the AEtemplate is made with the second procedure in callcustom. You shoudl look into AEcameraTemplate.mel for a good example
i woudlnt know how to access the option menu
well your a bit missuaing the attr thing, usually you want to pass $nodeName- Anyway usually you dont need to because you give a name to the meuitem you make, example:
then your usually doing things wrong, people almost instinctively use globals far too much, in 90% of cases theres really no meed for global even in cases that are shipped in autodesks built-in scripts. remeber names are global no matter what.
Hi jooj , thats great but i still have aproblem. The dropdown menu resets itself each time i select the node, and it seems like when i create a second instance of the node and change the menus value it also changes the value of the other menu... heres my code now
Well obviously if you need the data to be stored you need to connect the guitem to an attribute somehow, i was just doing what you were doing. That is making a gui item without actually making it do anything. Use a -changeCommand script to make the control do some persistent changes in the node and the edit proc update the values after they've been created to mach the selection.
Hi there again, so ive gotten the optionMenu working but i want to add a button beside it now to create soe custom nodes. The problem I'm having now is that i have a button with a -command that i want to call but I need so send an attribute to the procedure that i want to call and im not sure how. So heres an example