PDA

View Full Version : bin membership


mzee
01-30-2007, 09:00 PM
Hi!

I'm working on a script which creates 2 Bins which contains used and unused shader.
so far so good.
The script is working fine as long as i don't pipe e.g. a DGS-Shader through a surface-shader.
The script is checking if the shader is assign or not.
In this case the DGS-Shader isn't directly assign so the DGS-Shader is added to the unusedshader bin.

Here's a part of the script
**********************************************
{
string $userinput = `textFieldGrp -q -text hh_extension`;
if (size($userinput) == 0)
{
confirmDialog -m "Please fill in a Sets-Extension-Name!!!" -b "OK" -db "OK"; // do nothing
}
else
{
string $hh_selection[] = select (`ls -mat`);
string $hh_matname[] = `ls -selection`;

//For loop
for ($i = 0; $i < size($hh_matname); $i++)
{
hyperShade -objects $hh_matname[$i];

if (size(`ls -sl`) != 0)
{
pickWalk -d up;

sets -name ($userinput + "_" + $hh_matname[$i]);
select $hh_matname[$i];
select -noExpand `listHistory`;
binMembership -add $userinput;
select -cl ;
}
else
{
select $hh_matname[$i];
binMembership -add UNUSEDSHADER;
select -cl;
}}
}

**********************************************
select -noExpand `listHistory`; with this command the whole shading network is added to the used shader bin.

What worries me is the following:


else
{
select $hh_matname[$i];
binMembership -add UNUSEDSHADER;
select -cl;
}}

Here lies the problem - but i have no idea how i can fix this. All shaders that are not directly assign to an object will be added to unusedshader bin even if they are piped through a surfaceshader.

In this case i got not directly assigned shaders in both bins the usedshader bin and the unusedshader bin.

I really appreciate your help

laBetti
02-13-2007, 05:57 PM
hey mzee,

try the following:



string $hh_matname[] = `ls -mat`;
string $unused[]; clear($unused);
string $used[]; clear($used);
int $i, $j;

// loop through materials in scene
for ($i = 0; $i < size($hh_matname); $i++)




{// iterate through downstream nodes and check again for assigned objects


string $downStreamNodes[] = `hyperShade -lds $hh_matname[$i]`;

if (size($downStreamNodes) != 0)




{for ($j = 0; $j < size($downStreamNodes); $j++)






{hyperShade -objects $downStreamNodes[$j];


string $objWithMaterial2[] = `ls -sl`;
if (size($objWithMaterial2) != 0)




{// unused shader found


$used[size($used)] = $hh_matname[$i];


}




}




}


else




{// check for assigned objects


hyperShade -objects $hh_matname[$i];
string $objWithMaterial[] = `ls -sl`;
if (size($objWithMaterial) == 0)




{// unused shader found


$unused[size($unused)] = $hh_matname[$i];


}


else




{$used[size($used)] = $hh_matname[$i];




}




}




}



select $unused;
binMembership -add UNUSEDSHADER;

select $used;
binMembership -add USEDSHADER;



greets, betti

sinistar
05-06-2007, 01:49 AM
so how did this go? :)

CGTalk Moderation
05-06-2007, 01:49 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.