PDA

View Full Version : Navigating DG nodes to find fileTextureNode...what a nightmare!


octupe
09-07-2005, 02:17 PM
Hi,

I`m pretty new to MEL and I`m reading lots of good advise and help on this board as well as others.

I`ve been writing a script that will color a light based off the color at a point in a texture applied to some geometry. I`ve got all the light creation and setting the color ok, but I was stuck when trying to find out from an object what its filetexturenode was.
I read lots of posts and checked Brian Ewerts site many times and was gradually pulling more and more hair out. I didn`t want to come here asking until at least i had tried pretty much all possibilites and maybe got something half working anyway.

So i was reading all about listRelatives, listConnection, connectionInfo, listSets and anything related.

Now I am new to this,so thats probably not helping,but does it strike anyone else that trying to navigate through the DG to find what you are looking for is a nightmare of complexity? Surely it should be simpler to find out what is connected to what using MEL than it is, especialyl as the DG is at the heart of maya.

I now have something that is working basically and seems to work ok for a simple object with one shader with one filetexturenode attached.

here it is..its just in simplistic test form at the mo, I will splice it inot my main script later..

global proc WhatMapsIUse()

{


string $Selection[] = `ls -sl -sn` ;
string $ShadingGroup[] = `listSets -t 1
-ets
-object $Selection` ;
string $TokenClip[] ;

string $Shader = `connectionInfo -sfd ($ShadingGroup[0] + ".surfaceShader")`;

tokenize $Shader "." $TokenClip;

string $ShaderFileTexture[] = `listConnections -s true -d true $TokenClip[0]` ;

print ("ShadingGroup: " + $ShadingGroup[0] + "\n");
print ("Shader: " + $Shader + "\n") ;
print ("ShaderFileTexture: " + $ShaderFileTexture[0] + "\n") ;

}


If anyone has suggestions on how to improve this, then they will be most welcome.
And if anyone can contribute to this thread the best way to do this it would be great, because when I was tryingto find out how to do this it was very frustrating.

Thanks in advance for any help.

Although frustrating, I`m really enjoying getting in to MEL :)


Cheers

harmless
09-07-2005, 03:55 PM
It is maya's architecture's fault, not yours. For a treat try maxscript sometime. Here is its equivalent...


bitMapVal = #()
for obj in objects do
(
append bitMapVal (obj.material.diffuseMap)
)

thematt
09-07-2005, 07:42 PM
It is maya's architecture's fault, not yours. For a treat try maxscript sometime. Here is its equivalent...


bitMapVal = #()
for obj in objects do
(
append bitMapVal (obj.material.diffuseMap)
)



not the place for that..go flame somewhere else..


If anyone has suggestions on how to improve this, then they will be most welcome.
And if anyone can contribute to this thread the best way to do this it would be great, because when I was tryingto find out how to do this it was very frustrating.


take a look at "listHistory" command it will get you all the node connected to your object..then just isolate the file texture with "ls"

cheers


to help you out..:)

{

string $obj[] =`ls -sl `;

string $shader[] = `listHistory -f 1 $obj[0]`;

string $history[] = `listHistory $shader`;

string $files[] = `ls -type "file" $history`;

print $files;

}

GennadiyKorol
09-07-2005, 09:04 PM
edit: Nevermind:) Thought it was listConnections thing...

octupe
09-07-2005, 09:49 PM
Thanks thematt, I have a smile on my face.

The method I had arrived at did get me the info I needed but I knew it was not the best way.
Your solution is much simpler and elegant and I have found a new friend in the listHistory command :))

I think the hardest thing about MEL so far is not really the syntax or layout, but just becoming acquainted with what commands do what and what commands are useful for what.

Thanks again.

octupe
09-07-2005, 10:10 PM
thematt: You can supply a -type flag to the listHistory thing, so it will list only the nodes of the supplied type, this will make it even faster :)


I just tried with the -type flag and it came back with an error.







cheers,

GennadiyKorol
09-07-2005, 11:14 PM
Whooops!:) I've mixed it with listConnections command. Try it as well, it might help.

harmless
09-08-2005, 12:46 AM
Here is some simplicity:

string $sel[] = `ls -sl`;
string $matAry[] = `ls -materials $sel`;
string $texAry[] = `ls -textures $sel`;

neonoodle
09-08-2005, 07:31 AM
you could also get the shaders assigned to an object or group of objects with this command:

hyperShade -smn "";

thematt
09-08-2005, 08:33 AM
string $sel[] = `ls -sl`;
string $matAry[] = `ls -materials $sel`;
string $texAry[] = `ls -textures $sel`;

that would not work for what he intends because it would just list through a series of object to find the good one, what he want was to have one object only and find all the file texture related to it.



hyperShade -smn "";

didn't know about that one thanks...:)


I think the hardest thing about MEL so far is not really the syntax or layout, but just becoming acquainted with what commands do what and what commands are useful for what.


yep I understand exactly..though I'm still strugling with the syntax more than i should..


cheers

harmless
09-08-2005, 05:44 PM
Hi thematt,
If you select a single object with my script $texAry will be filled with all of the textures connected to that object. If you have any other questions please let me know.


Cheers

thematt
09-09-2005, 08:45 AM
If you select a single object with my script $texAry will be filled with all of the textures connected to that object. If you have any other questions please let me know.




have you try it?
because it really can't work..ls command only "list" what will be in the selection you gave it.
So if you give it only one transform, it will list texture in that transform and find none..since you select only one transform..unless I don't understand what you're trying to do (that could be possible).:shrug:

cheers

octupe
09-09-2005, 09:50 AM
have you try it?
because it really can't work..ls command only "list" what will be in the selection you gave it.
So if you give it only one transform, it will list texture in that transform and find none..since you select only one transform..unless I don't understand what you're trying to do (that could be possible).:shrug:

cheers

Yeah i tried this too and could not get it to give me a result for either $matAry or $texAry.



cheers,

CGTalk Moderation
09-09-2005, 09:50 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.