Go Back   Community for CG Artists > Graphic Software > Maya
New! Use your Facebook, Google, AIM & Yahoo accounts to securely log into this site, click logo to login  

Reply
 
LinkBack Thread Tools
Old 10-29-2011, 07:14 PM   #1 (permalink)
Registered User

 
Join Date: Oct 2011
Age: 24
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0 darkangel_f is on a distinguished road
Me script help

Hello, i just started to use Mel script,
i have made one script which create cubes and spheres,automatically.
i need the script to create lamberts, while it create the both shapes.
For the spheres to create and assign material Lambert RGB 1.0.0
and for the cubes to create and assign material Lambert RGB 0.0.1
i have this script but i can't changed it. =(
Can anyone help me?

MEL Script:
Code:
int $counter;

int $spheres[];

int $cubes[];

for ($counter=0; $counter<100; $counter++) 
{
$spheres[$counter] = $counter+1;
$cubes[$counter] = $counter+1;
};

int $var = 0;

for ($counter=0; $counter <100; $counter++)
{
if ($spheres[$counter]%2 )
{
polySphere - r $spheres [$counter];
move - r (10*$spheres[$counter]*cos($spheres[$counter])) (10*$spheres[$counter]*sin($spheres[$counter]))(20*$counter);



}
else
{
polyCube -ch on -o on -w $cubes [$counter] -h $cubes [$counter]-d $cubes [$counter]-cuv 4; 
move -r (10*$cubes[$counter]*cos($cubes[$counter])) (10*$cubes[$counter]*sin($cubes[$counter]))(20*$counter);
}
};

Last edited by darkangel_f; 10-30-2011 at 08:08 AM..
darkangel_f is offline   Reply With Quote
Old 02-24-2012, 04:02 PM   #2 (permalink)
Registered User

 
Join Date: Aug 2008
Location: Netherlands
Age: 35
Posts: 19
Thanks: 0
Thanked 2 Times in 2 Posts
Rep Power: 0 Controller is on a distinguished road
Mel

try this:

//ROOT!
//create a proc
global proc makeCubeNSpheres(int $count){
//TAB!
//run in the counter
for ($i=0; $i<$count; $i++)
{
//TAB!//TAB!
//create a cube and a sphere per iteration
string $cube[] = `polyCube`;
string $sphere[] = `polySphere`;

//check if the lambert alerady exists...
if (!`objExists "cube_shader"`){
//TAB!//TAB!//TAB!
//create RED and BLUE lamberts
string $materialBlue = `shadingNode -s -asShader lambert -n ("cube_shader")`;
string $materialRed = `shadingNode -s -asShader lambert -n ("sphere_shader")`;
setAttr ("sphere_shader.color") 1 0 0;
setAttr ("cube_shader.color") 0 0 1;
//TAB!//TAB!
}
//Out of the branch we assign the materials
//since they definitely exist by now and only once - Not 1 per loop!
assignSG "cube_shader" $cube[0];
assignSG "sphere_shader" $sphere[0];
//TAB!
}

//ROOT!
}
// run the proc and put whatever int number
// for the amount of spheres and cubes
// makeCubeNSpheres(666); - nah... will take some time
makeCubeNSpheres(1);

//PS - my side here is nice and tabbed, this forum is messing with me!
// this is sloppy!
// make sure to tab yours too whenever you enter a loop, branch, or proc
// if confused follow the "TAB!"

//Happy Coding! =]
Attached Thumbnails
Me script help-proccubensphere.jpg  
Controller is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Home - Archive - Top