API: Get assigned Material

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 01 January 2005   #1
API: Get assigned Material

Hi,

does anyone know how I can get the to an Object assigned material.. (eg. Lambert1)??? (In API)

Au'revoir,
Aya~
__________________
I aim for my endless dreams and I know they will come true!
Download the Koshigaya Maya Script Suite from http://www.koshigaya.de
 
Old 01 January 2005   #2
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[0]` == "transform")
 	$sel = `pickWalk -d down`;
 
 // list connections of type "shadingEngine"
 string $connections[] = `listConnections -t "shadingEngine"`;
 
 // if no shading engines found quit script.
 if(!size($connections))
 	error "no shaders attached";
 
 string $shaderEng = $connections[0];
 
 // 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[0];
 


any questions feel free to ask.
 
Old 01 January 2005   #3
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.
__________________
mike hovland
lead technical artist
Robomodo

Life beats down and crushes the soul... art reminds you that you have one. - Stella Adler
 
Old 01 January 2005   #4
Hi,

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 ^^

Au'revoir,
Aya~
__________________
I aim for my endless dreams and I know they will come true!
Download the Koshigaya Maya Script Suite from http://www.koshigaya.de
 
Old 01 January 2006   #5
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 01:54 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.