This problem has me going around in circles. I have a script that I am making that will compare two texture paths and if they are the same select the faces assigned to one shader and assign them to the other.
The problem comes in when trying to select the faces assigned to the shader that is related to the first texture node.
It is not working currently because i can not find a command to transfer the selection to the shader from the texture node. I have tried the pickWalk command, the connectionInfo, listHistory -future, and have found the best results with listConnections -destination on. Unfortunately when I use the listConnections i get a materialinfo node as well as a defaultTextureList node, which are further down the hierarchy somewhere.
This portion of the code currently looks like this:
select $texNode[$j];
select -ne listConnections -source 0 -destination 1 texNode[j];
//$shader = connectionInfo -dfs texNode[j];
$shader = ls -sl; //ls -sl -typ shader;
print $shader;
hyperShade -o $shader;
and the objects selected look like this...
materialInfo4
defaultTextureList1
(desired shader)
The second portion is easy because maya has a way to assign a shader directly to the selection from the texture node.
//assigns faces from first shader to second shader
hypergraphAssignTextureToSelection $texNode[$k];
So, any number of solutions would be nice,
1) a way to limit the listConnections function to only the first direct connection, which you can see above I was trying to do with the connectionInfo but had to comment out.
2) a way to limit the selection to only a certain type when it is read into the $shader variable after the listConnections, which i also tried but commented out because i could not find the specific type for a shader.
3) a way to query the faces assigned to a given shader according to the texture node itself, in much the same way that the hypergraphAssignTextureToSelection assigns with just the texture node specified
Anyone who knows specifics on any of these solutions, or any help at all would be greatly appreciated.
Thanks,
the bird