View Full Version : API: Get assigned Material
01-10-2005, 01:30 PM
does anyone know how I can get the to an Object assigned material.. (eg. Lambert1)??? (In API)
01-11-2005, 02:07 PM
this worked on a quick test I did but I can't imagine it would work on a more coplex structure.
I think the way to go around this is to check the connections of the shape of the object until you find the shaderEngine and then list the connections again to find the material that is connected to that shaderEngine.
// get selection
string $sel = `ls -sl -fl`;
// check if selection is the shape, if not get the shape of the selection
if(`nodeType $sel` == "transform")
$sel = `pickWalk -d down`;
// list connections of type "shadingEngine"
string $connections = `listConnections -t "shadingEngine"`;
// if no shading engines found quit script.
error "no shaders attached";
string $shaderEng = $connections;
// get the node that is connected to the shading engine's surfaceShader attribute
$connections = `listConnections -source 1 -destination false ($shaderEng + ".surfaceShader")`;
// $shNode is the name of the material attached to the object
string $shNode = $connections;
any questions feel free to ask.
01-11-2005, 03:48 PM
What tomViolet wrote looks like it will work, of course this is using MEL, which you are able to do through the API, but it can be slow. I would recommend trolling through the API docs to find out how to do this strictly in a plugin.
01-12-2005, 06:44 AM
thanks ^^ but i need it in API anyway.. won't use MEL via API :)
I've done it allready trough looking at the Conenctions via API and so I can get the SG... but i hope there's still a better way ^^
01-20-2006, 10: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-2014, Jelsoft Enterprises Ltd.