PDA

View Full Version : Mel-Script is killing me


Apophis3d
01-21-2008, 03:48 PM
Ok I need alittle help here guys. This script is for my Mel Scripting class and it's kicking my butt right now. What I have to do is make this script that parrents objects to the cube it creates. Then the script reports back that the cube was created and tells you how many objects it parrented to itself. It has to be done using the ls command. Any ideas here I am pretty lost....

global proc parentme()
{
string $cube[]= `polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
string $sel[] = `ls -selection`;
// Result: pCube1 polyCube1 //
move -relative -5.641727 0 0 ;
parent;
int $size = `size ($sel)`;
print ($cube[0 ] + "Has givin birth and is now the parrent of\n");
print ($size + "baby objects");
}

geonak
01-21-2008, 03:58 PM
string $cube[]= `polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
string $sel[] = `ls -selection`;

by writing this you will obtain in $sel your cube object since it gets selected after its creation
invert the 2 lines , then specify params in the parent command or reselct the objects in the corresponding order then do the parent without params
if you need more expl just ask
Regards

Apophis3d
01-21-2008, 04:04 PM
Yeah i am still alittle confused although it's starting to make more sense

Apophis3d
01-21-2008, 04:10 PM
Ok it took me a few minutes but I got it to work this is what it looks like.

global proc parentme()
{
string $sel[] = `ls -selection`;
string $cube[]= `polyCube -w 1 -h 1 -d 1 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -cuv 4 -ch 1`;
// Result: pCube1 polyCube1 //
move -relative -5.641727 0 0 ;
parent $sel $cube[0];
int $size = `size ($sel)`;
print ($cube[0 ] + "Has givin birth and is now the parrent of\n");
print ($size + "baby objects");
}

thanks for the help

siproductions
01-21-2008, 09:38 PM
$selected = `ls -sl`;
$sizeSel = `size $selected`;
$cube = `polyCube`;
for ($sel in $selected)
{
parent $sel $cube[0];
}
print ("Cube was created and had " + $sizeSel + " children parented to it.");
clear $selected;
clear $cube;

CGTalk Moderation
01-21-2008, 09:38 PM
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.