cgTantra.com - LEARN INSPIRE GROW

Go Back   cgTantra Forums > Art & Techniques > General 3d Techniques
Reply
 
Submit Tools Thread Tools
Old 21-07-2012, 06:41 PM   #1
blovcandyman
Novice
 
Join Date: Oct 2009
Posts: 15
Blog Entries: 1
Rep Power: 0
blovcandyman is on a distinguished road
Question Need MEL script for switch of oobjects "cast shadow" and "Receive Shadow" attribute.

Hi.

I am new to MEL. I have bunch of cylinders. I need to uncheck their "cast Shadow" and "Receive shadow" attribute from Render stats all at once. I selected all the objects and unchecked those attributes but the result is only one object got the change. So i have to select one by one each to change the attr, i dont want that, and tedious job too. Plz help me to acieve thru MEL...

Last edited by blovcandyman; 21-07-2012 at 06:43 PM.
blovcandyman is offline   Reply With Quote
Old 24-07-2012, 05:09 PM   #2
omkarjere
Tantrick
 
Join Date: May 2011
Location: Pune
Posts: 309
Rep Power: 3
omkarjere is on a distinguished road
Default

I will tell you both the methods to do it Manually as well as with MEL

Manual Method:

1. Select all the objects which you want to modify.
2. Go to Window>General Editors>Attribute Spreadsheet.
3. Switch to "Render" tab in there.
4. Now you can turn On to Off for both "Cast Shadows" and "Receive Shadows" option by selected the first column under the name of the attribute(for e.g Cast Shadows) then hold shift and click the last column(vertically) then enter 0(for off) or 1(for on).


Using MEL:

Note: Only select the objects you wish to modify and then run the following script.

Quote:
// Get the selected objects
string $sel[] = `ls -sl`;

// Counter Variable
int $i;

// Use the for Loop to un-check each objects.castsShadows
// objects.receiveShadows.

for($i = 0; $i < size($sel); $i++) {
// Need to get the shapeNode for each object
// as the .castsShadows/.receiveShadows attributes
// are located there
string $shape[] = `listRelatives -shapes $sel[$i]`;

// Set both to zero
setAttr ($shape[0] + ".castsShadows") 0;
setAttr ($shape[0] + ".receiveShadows") 0;

// Clear the $shape array
clear $shape;
}
Copy the above script to the script editor then select it and Middle Mouse drag to the shelf so you get a button for it . To use simply select the objects you want to disable these attributes for and hit the shelf button.
__________________
My MEL scripts:
http://www.creativecrash.com/users/o...free_downloads

Fun effect with Maya Dynamics:
http://www.youtube.com/watch?v=4ETQpsUYJ8U
omkarjere is online now   Reply With Quote
Reply


Thread Tools

Forum Jump

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | © 2009 CGTantra | Privacy Policy | All times are GMT +5.5. The time now is 10:02 PM.

Choose Your Color         Facebook              CGTantra Toolbar  Contact Us - cgTantra Home - Archive - Top