Home Technical Talk
The BRAWL² Tournament Challenge has been announced!

It starts May 12, and ends Sept 12. Let's see what you got!

https://polycount.com/discussion/237047/the-brawl²-tournament

[Melscript/python] Selecting influenced polygons from a joint

StephenVyas
polycounter lvl 20
Offline / Send Message
StephenVyas polycounter lvl 20
What I'd like to code is:

With a rigged character
If I select a specific joint. I'd like to run the script, which would return the selection of polygons influenced by that specific joint.
(As if I manually went into face mode and started selecting the polygons one by one)

Have no idea where to start on this one. Any ideas?

Replies

  • jfeez
    Offline / Send Message
    jfeez polycounter lvl 8
    I quickly tried this. Not entirely sure how to select faces, need to look around the documentation abit, i tried polyInfo but the results where wierd.. anyway
    1. import maya.cmds as cmds
    2.  
    3. #get the skin cluster and the joint
    4. selection = cmds.ls(sl=True, fl=True)
    5. jointSelection = cmds.ls(sl=True,type = "joint")
    6.  
    7. #we need the shape node to get the skincluster connection
    8. relatives = cmds.listRelatives(selection, type = "shape")
    9. sCluster = cmds.listConnections(relatives, type = "skinCluster")
    10.  
    11. #get the joints in the skincluster
    12. skinInfluences = cmds.skinCluster(sCluster[0],q=True,inf=True)#get skinCluster
    13. cmds.select(cl=True)
    14. #loop through each influence in the cluster until it is the joint you want to query
    15. for influence in skinInfluences:
    16. if jointSelection[0] == influence:
    17. cmds.skinCluster(sCluster[0], e=True, selectInfluenceVerts = influence)

    This is pretty simple and will work for one joint. Just select the joint and the geo u wanna query and it will return the verts. There is loads more you could do if you wanted to. Hopefully this all makes sense =D
  • StephenVyas
    Offline / Send Message
    StephenVyas polycounter lvl 20
    Thanks for doing the heavy lifting , jfeez!
Sign In or Register to comment.