Get selection’s shader

There are times when you want to quickly select the shader applied to the selected object rather than switching between various tabs in the Attribute Editor or going through the numerous shaders in the Hypershade. You can use the following mel script to automate this task.

[cpp]

string $shaderName[] = stringArrayRemoveDuplicates(
ls("-mat", listConnections( listConnections("-type","shadingEngine",`ls -sl -o -dag -s`))
)
);
select -r $shaderName[0];
Most men have occasionally experienced difficulty with their penis in staying firm. buy generic viagra like this Thus this is generic levitra online how the drug works.There are several warnings regarding this drug. The tools provide you lowest prices cialis with intelligent engagement metrics about what can help keep the customers engaged for longer durations and furnish you with positive results. Medication are expensive but a lifestyle change is very important along with using the herbal products. free samples of cialis foea.org
[/cpp]

We are using an Array ( $matName[] ) here so that we can select the first shader returned from the list of multiple shaders (just in case) applied to one object.

stringArrayRemoveDuplicates remove all duplicate items from a string array. There will be only one occurrence of each string item in the returned string array.


Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.