View Full Version : Find material on object
01-07-2005, 09:08 PM
I am trying to find the material of a selected object. This is how I am trying to do it but it does not seem to be working. I am just printing the variable at the end to test it. I have also tried one or two other things that did not work for me.
$selectedSkin = `ls -sl`;
$selectedMaterial= `ls -mat $selectedSkin`;
Thanks for any help
01-09-2005, 01:29 AM
Here's somethoing quick and dirty. If I was doing this for real, I'd do a little more checks/verification. The concept is that the material connections are to the shape node of an object, not the transform. The connection to the shape is the shading engine, so once that is found, find the material. If anyone else has comments or something to add, please do so. Cheers!
string $objects = `ls -sl`;
// Find the material for each object in the selected list
for ( $obj in $objects )
print ( "Object: " + $obj + "\t");
// If the object selected is a transform, find the shape node
if ( `objectType $obj` == "transform" )
$objectShapes = `pickWalk -d down $obj`;
// List connections of type Lambert, 'cause the basic materials
// are all derived from Lamberts
$shadingEngine = `listConnections -s false -d true -type shadingEngine $objectShapes`;
if ( `objectType $shadingEngine` == "shadingEngine" )
$material = `listConnections -type lambert $shadingEngine`;
// Assign this to another variable
print ( "Material: " + $material + "\n" );
01-10-2005, 10:18 PM
Mark, thanks for the help. I had put something together myself when you had posted.
$shade=`listSets -t 1 -ets -o $s`;
string $connections = `listConnections -d 0 -s 1 $shade`;
$material = $connections;
$transparency = $material+".transparency";
setAttr $transparency -type double3 .5 .5 .5;
01-20-2006, 09:00 AM
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.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.