View Full Version : Select faces by material

12 December 2003, 12:44 PM
I use the command hyperShade -objects materialName; to select all faces with a certain material.
The problem is that this select all faces with the material on every object in the scene, and I want to select only the faces with the material on a certain single object.

What is the easiest way to get from objectName and materialName to a face selection on the object with that material?

12 December 2003, 03:11 PM
Ok, I've put something together that sorta works, but it is very clumsy. Who can point me to a better way to do this?


// select objects from scene
string $objectName[] = `ls -sl -fl`;

// get first object
$newObject = $objectName[0];
$newMaterial = "wall";

string $newList[];
clear $newList;

// select all faces with material
hyperShade -objects $newMaterial;
string $faceList[] = `ls -selection -flatten`;
int $numberOfFaces = size($faceList);

for ($v=0; $v<$numberOfFaces; $v++)
// strip to objectname only
string $faceExtension = "." + match("[^\.]*$", $faceList[$v]);
string $test = substring($faceList[$v], 1, size($faceList[$v]) - size($faceExtension));

// if object is from selected object put face path to array
if($test == $newObject)
$sizeNewList = size($newList);
$newList[$sizeNewList] = $faceList[$v];

select -r $newList;

12 December 2003, 10:34 PM

first select all of the target object's faces either by mouse or mel then use

string $tempset = `sets`;
string $tempgrps[] = `listConnections -type shadingEngine blinn1`;
select `sets -int $tempset $tempgrps[0]`;

substitue blinn1 for whatever material you're looking for.

12 December 2003, 10:33 AM
aaah, that's the kind solution I was looking for, thanks! :)

CGTalk Moderation
01 January 2006, 08:00 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.