Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   How can I list all objects in a Maya scene in a roll-down list with MEL? (https://simplymaya.com/forum/showthread.php?t=7554)

vern 20-08-2003 03:56 PM

How can I list all objects in a Maya scene in a roll-down list with MEL?
 
Hi,

I am making a GUI with MEL and I want to list all objects in the Maya scene (both selected and unselected) when the GUI open. Right now I am just writing my own labels to choose from, but I would like to generate the list from the scene. How can I get hold of all objects in scene to this list?

optionMenuGrp -label "Objects";

menuItem -label "Sphere";
menuItem -label "Ball";
menuItem -label "Cube";

THANKS,

veronica

mtmckinley 20-08-2003 04:33 PM

what about the Outliner? Window > Outliner

dannyngan 20-08-2003 04:36 PM

You should look up the "ls" command in the MEL command reference.

vern 26-08-2003 12:21 PM

Still problem with listing objects! Help appreciated!
 
Hi,

Thank for the help about using the ls command. I can understand that I can obtain all objects in the scene with this one now. But I have still a problem with how to list it in my optionMenuGrp. Can anyone help me with this?

// List all objects in the scene
string $allObjects[];
$allObjects = `ls`;
optionMenuGrp -label "Objects";
menuItem -label $allObjects;

I guess the step were I put the string as one of the labels in the optionMenuGrp is were I do the wrong thing. Can I use this command at all to list the objects in the scene in this list?

I can run the script but the result in the list becomes only "time1" even though I have created a sphere in the scene.

dannyngan 30-08-2003 07:42 PM

It's possible that you may not be able to use a string array as a single menuItem. You might have to create a separate menuItem for each entry in the array. I haven't tried this myself though. Give it a shot and see what happens! :)

vern 01-09-2003 05:12 PM

Hi,

This is one SOLUTION of the problem:

// List all objects in the scene
string $allObjects[];
string $tempName;
$allObjects = `ls -g`;
optionMenuGrp -label "Objects";
for ($tempName in $allObjects)
{
menuItem -label $tempName;
}


It seemed to work for me, thanks for help. If anyone knows how to select an object in the scene depending on which one is selected from this please write a post. I think I will have to use the select command in combination with the changeCommand flag for the optionMenuGrp, but I am not sure. :)

/veronica


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

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