View Full Version : select by type : utility nodes


untelon
03 March 2007, 10:23 PM
I was wondering if any of you knew a way of selecting all utility nodes via mel. I am able to select all materials using select -r `ls -mat`; or all textures using select -r `ls -tex`; etc.

I know that I may invoke the hypershade command : hyperShadePanelMenuCommand("hyperShadePanel1", "selectUtilities"); which will do the trick, yet I am looking for command line mode as running the above in a batch render will cause an error (no GUI present).

If anyone knows of a way, please do let me know. As of right now the best I can do is list each utility node type such as select -r `ls -type place3dTexture`;

The purpose of my script is to remove redundant shading networks of imported files (I wish import would have an overwrite existing nodes option) via a mel script.

BTW The same goes with the shadingEngines. Even thought when I query the node type using ls -sl -showType it returns "shadingEngine" as the type, I am unable to select them using "select -r `ls -type shadingEngine`... Is there a way of selecting these using mel?

Thanks.

Jim

Soviut
03 March 2007, 08:00 AM
You might just have to build a helper procedure which checks every possible utility node type against the nodeType command. For example...


global proc SelectAllUtilityNodes()
{
string $utilityNodeNames[];
string $foundNodes[];

$utilityNodeNames = {"arrayMapper", "bump2d", "bump3d", "condition", "distanceBetween", "heightField", "lightInfo", "multiplyDivide", "place2dTexture", "place3dTexture", "plusMinusAverage", "projection", "reverse", "samplerInfo", "setRange", "stencil", "uvChooser", "vectorProduct"};

// clear the current selection
select -cl;

for ($nodeName in $utilityNodeNames)
{
$foundNodes = `ls -type $nodeName`;

for ($foundNode in $foundNodes)
{
select -add $foundNode;
}
}
}



Right now, the procedure only select General Utilities. To include Color Utilities, Twitch utilities, etc. you need to add the node names to the $utilityNodeNames array. The best way to get the node name is to simply go into your hypershade, click on each node in the sidebar to create one, and then look at the name returned and remove the number from the end. eg. "distanceBetween1" 's node name is "distanceBetween".

Its not a totally automatic solution, it may not even be the "best" solution, but it seems to work.

kjaft
03 March 2007, 02:40 PM
Check out the "getClassification" command, it returns you the type of rendering utility, like "utility|general" etc.

untelon
03 March 2007, 07:14 PM
Thank you all again. Simply put, no easy shortcut. I have to hardcode the classification, I just thought maybe there was a select all by type shortcut... It's all well.

Thank you again

CGTalk Moderation
03 March 2007, 07:14 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.


1