PDA

View Full Version : Another tricky selection


andymoorer
11-30-2009, 10:16 PM
Ok, mel noob here with another tricky selection question.

I need a user selection of verts on two separate meshes. I can create a list of the selected verts easily enough:

string $sel[] = `ls -fl -sl`;

But I also need to get a list of the two parent meshes. I can get the parent of each vertex in a list...

$parents = `listRelatives -p $sel`;

But of course the list created is the parent shapes over and over, listed once per vertex. Sloppy, that, I want just a simple list of two objects.

Can I filter my existing selection of verts into a selection of parent meshes?

andymoorer
11-30-2009, 10:31 PM
I should add - I can get the desired list by walking thru the duplicates of the list of vert relatives like so:


// get verts
string $sel[] = `ls -fl -sl`;

//Create kludgy list of parent of each vert:
$parents = `listRelatives -p $sel`;

string $parentMeshes[]; clear $parentMeshes;

int $count =0;
string $last = "last";
for($i=0;$i<size($parents);$i++) {

if ($parents[$i] != $last){
$last=$parents[$i];
$parentMeshes[$count]=$parents[$i];
$count ++;

}
}
print ($parentMeshes);


... but this feels hacky and stupid....

jaydru
11-30-2009, 11:49 PM
a little less hacky for you :)

string $shapes[] = `ls -o -sl`;
string $transforms[] = `listRelatives -p $shapes`;


james.

andymoorer
12-01-2009, 05:20 PM
Aha, that's great, thanks. Every time I think the ls command has let me down the problem turns out to be.... me.

CGTalk Moderation
12-01-2009, 05:20 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.