getAttr material attributes


#1

when i am selecting a shader if there no file (image) in common material attributes(transparency) not getting any result.

string $transpar[] = ls -sl -typ lambert;

string $checkou[] = listConnections -d off -s on ($transpar[0]+".transparency");

for ($yups in $checkou) {

if (objExists "file *") {

print (“Wrong”);

} else {

print (“Done”);

}

}


#2

Please use the ‘#’ tag for code, it makes the program easier to read.
Could you please tell us exactly what you want to do and where your script fails?
This line in your code:

if (`objExists "file *"`) {...

is not useful at all because it simply checks if there is node called “file *” what is never true.


#3

if any material(ex :- Lambert) has connected to file in transparency,
i need to get the result it has connected to file or not.

if it has connected i need to get result value 1.
if it not connected i need to get result value 0.

using mel script…

can u plzzzzz help me…


#4
string $sel[] = `ls -type lambert`;
for( $s in $sel)
{
	string $attr = $s + ".transparency";
	string $inConnections[] = `listConnections -d 0 -s 1 -type "file" $s`;
	if( size($inConnections) > 0)
		print($s + ".transparecy has connection to a file node.
");
	else
		print($s + ".transparecy has NO connection to a file node.
");
}


#5

thnx dude your script helped a lot…

how can i get the number of connected files in int values result,
like (if there are 2 files in the scene the result should be 2);

file 1,
file 2,

result = 2;


#6

If you only want to count the number of found files, you define a int variable before the loop and increment it if a file was found. If you only need the number of element in the array you can check it with:

int $len = size($nameOfYourArray);


#7

this is the code u gave to me how to count the number of files and get the result.

string $sel[] = ls -type lambert;
for( $s in $sel)
{
string $attr = $s + “.transparency”;
string $inConnections[] = listConnections -d 0 -s 1 -type "file" $s;
if( size($inConnections) > 0)
print($s + ".transparecy has connection to a file node.
");
else
print($s + ".transparecy has NO connection to a file node.
");

}


#8

If you write a message, there is a ‘#’ sign in the toolbar to mark text as code, it encloses the selected text with code tags. Please use it to make your code better readable.

string $sel[] = `ls -type lambert`;
int $numberOfFiles = 0;
 for( $s in $sel)
 {
	string $attr = $s + ".transparency";
    	string $inConnections[] = `listConnections -d 0 -s 1 -type "file" $s`;
	if( size($inConnections) > 0)
	   $numberOfFiles += 1;
 	}
print("Number of connected files: " + $numberOfFiles + "
");


#9

Thanx Dude you helped me alot… :wavey:


#10

I have a one more doubt plzzzzz help me…

How to assign multiple shaders (eg :- 5 shaders) randomly to ‘n’ number of objects in a layer…

i am assigning randomly RGB matts to the ‘n’ (eg :- 50 or 100 or so on…)objects in layer using mel but i am not getting result.

and one more thing same shader should not assign side by side…


#11

What exactly do you mean by:

“and one more thing same shader should not assign side by side…”

Does that mean you do not want to have the same shader assigned to objects which has a neigbour with the same shader?


#12

yes…

should not come same shader side by side…


#13

This is a bit more complicated. Too much work at the moment, so I can’t help.


#14

ok when you are free you can send me…


#15

if there is any file node for color attribute it is also getting count,
it should not count the any other attributes file node,
it should count only transparency attribute file node.

string $sel[] = `ls -type lambert`;
int $numberOfFiles = 0;
 for( $s in $sel)
 {
	string $attr = $s + ".transparency";
    	string $inConnections[] = `listConnections -d 0 -s 1 -type "file" $s`;
	if( size($inConnections) > 0)
	   $numberOfFiles += 1;
 	}
print("Number of connected files: " + $numberOfFiles + "
");

#16

How to find out material from render layer what has assigned to it (ex :- Occlusion & Z_depth)


#17

How to find out material from render layer what has assigned to it (ex :- Occlusion & Z_depth)