How to select meshGeo that is skinned to joint using Mel?

How to select meshGeo that is skinned to joint using Mel?

mostly_human
Advocate Advocate
2,071 Views
4 Replies
Message 1 of 5

How to select meshGeo that is skinned to joint using Mel?

mostly_human
Advocate
Advocate

If I only have a reference to a joint how do I select the mesh that the joint is skinned to? Thanks in advance for any help it is much appreciated!

0 Likes
Accepted solutions (2)
2,072 Views
4 Replies
Replies (4)
Message 2 of 5

lee.dunham
Collaborator
Collaborator
  1. Find the skin clusters (there could be more than one) connected to the joint.
  2. Get the mesh using the skin clusters.

 

Untested but should give the idea.

 

$skins[] = `listConnections -type "skinCluster"`;
$mesh = `skinCluster -geometry $skins[1]`;

 

Would recommend switching to python if you're able to.

 

Message 3 of 5

osidedan
Advocate
Advocate
Accepted solution

What lee.dunham suggests will definitely work! He mentioned it is untested, so I gave it a quick test, and you just need to add a variable type on the first line, and a query flag on the second line for it to work:

string $skins[] = `listConnections -type "skinCluster"`;
$mesh = `skinCluster -q -geometry $skins[1]`;

 

Edit:
if you need to select the mesh, add this at the end:

select -r $mesh;

and if you need to select the transform instead, add this at the end instead:

$transform = `listRelatives -parent $mesh`;
select -r $transform;
0 Likes
Message 4 of 5

mostly_human
Advocate
Advocate
Accepted solution

Thanks guys, very much appreciated!

Message 5 of 5

mspeer
Consultant
Consultant

Hi!

 

@mostly_human 

Please mark every answer that solves your problem (or gives the correct answer) as solution, so others interested in this thread will get a better overview.

You can of course also mark your own reply as solution if it contains a solution or a "correct" answer.

0 Likes