Home Technical Talk

[Melscript/python] Selecting influenced polygons from a joint

StephenVyas
polycounter lvl 18
Offline / Send Message
StephenVyas polycounter lvl 18
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
    Options
    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
    import maya.cmds as cmds
    
    #get the skin cluster and the joint
    selection = cmds.ls(sl=True, fl=True)
    jointSelection = cmds.ls(sl=True,type = "joint")
    
    #we need the shape node to get the skincluster connection
    relatives = cmds.listRelatives(selection, type = "shape")
    sCluster = cmds.listConnections(relatives, type = "skinCluster")
    
    #get the joints in the skincluster
    skinInfluences = cmds.skinCluster(sCluster[0],q=True,inf=True)#get skinCluster
    cmds.select(cl=True)
    #loop through each influence in the cluster until it is the joint you want to query
    for influence in skinInfluences:
    	if jointSelection[0] == influence:
    		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
    Options
    Offline / Send Message
    StephenVyas polycounter lvl 18
    Thanks for doing the heavy lifting , jfeez!
Sign In or Register to comment.