Getting objects with a specified material

Hi.

I have the name of a specific material, and would like to get all the meshes that the material applies to.

e.g. given the material name "lambert2" I get the following results:

polySurface2248.f[201]
polySurface2248.f[218:219]

I can get the information by using Multilister, but I'm trying to get the info via MEL.

Any help would be great, thanks.

here is one way, may not be the best method for what your doing, but it should work.

//-----
hyperShade -objects lambert2;
string $faces[]=ls -sl;

//------

Hope that helps
--g

Agree with GDC.
But if you work with polygons, i think it's beter to use
"filterExpand -sm 34 -ex 1" instead of "ls -sl". It allows you to avoid such replies like "f[10:30]".

Or "ls -selection -flatten" Will give you the individual faces not aglob!

Agreed! but the orignal post said the results should be:

poly.f[218:220];

--g

Note: I've pasted my script in a couple times now, and every time I post it in, not only does the formatting get screwed up, but the "for" loops loose a bunch of their code. I aplogoize, but I don't know what's going on

I have a proc written to do this stuff. Select a material from the Hypershade (not multilister... the multilister dosen't "select" things by default), and it will select the nodes it's assigned to, plus list them in the script editor:

global proc EP_listShadedElements()
{
string $material[] = ls -sl;
if (size($material) != 1)
error "Please select only a single Material";
text -e -l ("Shader Name: " + $material[0]) T_PSF_shaderName;
string $destinationConnections[] = listConnections -s 0 -d 1 $material[0];
for ($a=0; $a {
if (objectType -i "shadingEngine" $destinationConnections[$a])
{
string $shadingEngine = $destinationConnections[$a];
string $setMembers[] = sets -q $shadingEngine;
for ($b=0; $b {
setParent CL_PSFelements;
button -l ("Select: " + $setMembers[$b]) -c ("select -r " + $setMembers[$b]);
}
}
}
}

Thanks for the replies, it's exactly what I needed.

Hi Warpcat,

I'm still rather new to MEL and was wondering about your syntax here? The "for ($a=0; $a{" is confusing me...is it shorthand for something?

Thanks,
-bN

You work at Spark? Ask Lonnie... he can tell you ALLLL about it. Tell him Warpcat in San Francisco says hi