PDA

View Full Version : mia_ shader connection button


thehive
07-12-2007, 07:36 PM
im learin mel on an off i was wonder how to setup this mel script so u can make the default connects with out have to mmb drag over the shading_group , basicly if u ha a bunch of mia shader u can select them an make all the connettons this is what i got so far. the prob i need to define the shader an the shading group no matter what the name is. haveing "$sel" mean its only one obj i nees 2 the shader an shading group any thoughts


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

print $sel;

for ($obj in $sel)

{


connectAttr -f $sel.outValue $sel.miPhotonShader;
connectAttr -f $sel.outValue $sel.miShadowShader;
connectAttr -f $sel.outValue $sel.miMaterialShader;

}

trancor
07-12-2007, 08:42 PM
Don't really understand exactly what you are trying to do, but it sounds like you want to just have object's attributes link up to other attributes. Sorry for the lack of complete understanding, but maybe this will help a little below -


connectAttr -f ($obj+".outValue") ($obj+".miPhotonShader");
connectAttr -f ($obj+".outValue") ($obj+".miShadowShader");
connectAttr -f ($obj+".outValue") ($obj+".miMaterialShader");


I'm asuming you were having a problem with the code, rather then expanding it? The variable needs to be ($obj+".outValue") not $obj.outValue.

the for loop you made is set up right but you also used the wrong variables in the loop itself -

for ($obj in $sel){
print $sel; // This will print the array
print $obj; // This will print the current object the loop is working with.
}


This wouldn't work for objects, this is a shader node script, correct?

thehive
07-12-2007, 08:45 PM
yea for shaders , i didnt know how to incase the shder + the sg tag on it so it would know that its connecting the outvalue to the shading group mi parts

trancor
07-12-2007, 08:48 PM
One way you can do this is by going to the attribute you want to connect up, change the value slightly, and look in the script editor, you'll see the exact line you want to link to in your mel

edit - haha, I must be tired or something, you just want a runner of some sort to count up the shaders you are connting what to what?

trancor
07-12-2007, 08:54 PM
bugga, ok, I'm going to try posting again with a little bit more of a focused mind, sorry for my meandering mind.


if you have a list of like 5 shaders, and they are numbered 1 2 3 4 5 and all with SGs at the end. Try a different type of for loop -



for ($i=0; $i<size($sel);++$i){
//this way, if you -
print $i;

//it will print the number you are working with currently. For the sg groups you can -

connect ($sel[$i]+"blinn"+$i+"SG.outValue") ($sel[$i]+".miPhotonShader");
}


the $sel[$i] will read what number element in the array the For loop is working with.

Sorry for the bad example, but does this help any?

thehive
07-12-2007, 09:45 PM
i see what your say to list them then add them back in along with the "sg"

i did the attribute this to see what maya was doin this is how i got this far hehe

CGTalk Moderation
07-12-2007, 09:45 PM
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.