Get selected joints from weights manage



  • On 13/04/2014 at 10:43, xxxxxxxx wrote:

    Can someone point me in the right direction for finding out which joint or joints is selected in the Weight Manager or the Weight Tool? I cannot seem to figure out how to tell. I can't even find the right ID of the list there.

    If anyone can shed some light that would be great(and could maybe lead me to finishing some helpful weighting scripts for CINEMA).



  • On 17/04/2014 at 14:41, xxxxxxxx wrote:

    It is unfortunately not possible to read the tree/list information from these tools as the datatype
    is not accessible from Python.

    Best,
    -Niklas



  • On 17/04/2014 at 14:43, xxxxxxxx wrote:

    Damnit. Thats a major problem. Is there any way you can think of to get those joints? This limits a lot of scripts for weighting big time.



  • On 17/04/2014 at 15:43, xxxxxxxx wrote:

    I was waiting to hear from someone else to confirm my findings.
    Niklas has confirmed my findings about the tree GUI.

    The only way I could find to get at the joints in the WM is by going through the tag.

    Example:

    #The Weights Manager is used to access the weight values stored in the Tweights tag on the mesh object  
    #We can't iterate through the "Joints" list tree gizmo in the WM using GetFirstObject(), GetNext(), etc.. like the OM tree gizmo  
    #But the Tweights tag has some functions in it that can help us deal with that limitation  
      
    import c4d  
    def main() :  
      
      #The Character mesh that has joints deforming it  
      mesh = doc.SearchObject("Cube")   
      
      #The weights tag on the mesh..Which we need to cast to a CAWeightTag type in C++  
      wtag = mesh.GetTag(c4d.Tweights)  
      
      #The number of joints in the Weight Manager's Joints list  
      #NOTE: Objects other than joints can also be binded and included in this list as well as joints...like the Root nulls  
      jcount = wtag.GetJointCount()  
      print jcount  
      
      """This gets an object in the OM using the index# of an object in the Weights Manager's Joints list  
      This lets you do things like select objects in the OM based on it's WM index value  
      NOTE: The WM lists things alphabetically...Not how they exist in the OM  
      NOTE: Objects other than joints can also be binded and included in this list as well as joints...like the Root nulls"""  
      jnt = wtag.GetJoint(0, doc)  # 0 == The first object in the WM Joints list  
      print jnt.GetName()  
      
      #This code returns the Weight Manager's index value for a joint (or other object) in the OM  
      #REMEMBER:The order they're listed in the WM can be different than the OM  
      jnt2 = doc.SearchObject("Joint.2")     
      findWMIndexNum = wtag.FindJoint(jnt2, doc)  
      print findWMIndexNum  
      
      #The total number of weights stored in the specified joint(or object) in the WM Joints list  
      wtcount = wtag.GetWeightCount(0)  
      print wtcount  
        
        
      #This code lets us change the weight values for a specific joint and a specific mesh vertice  
      # 1==The joint object by index# in the WM,  0==The point index# in the mesh  
      # 0.0 is the weight value we're setting   
      wtag.SetWeight(1, 0, 0.0)  
      
      #This lets us check the weight values for a specific joint and a specific mesh vertice  
      # 1==The joint object by index# in the WM,  0==The point index# in the mesh  
      wt = wtag.GetWeight(1, 0)  
      print wt  
      
      c4d.EventAdd()  
      
    if __name__=='__main__':  
      main()
    

    -ScottA



  • On 17/04/2014 at 17:50, xxxxxxxx wrote:

    Thanks for the effort, scott. I was aware of that method of gathering weights and such, however i was wanting to get the selected joint from the tree view because there are times where you want to do things to only the specified joint. So with no way to specify id have to be explicitly passing in a joint name which just wont work. If i was able to query the selected joints in the weights manager i could figure out that joint, its index, and only affect that joint.



  • On 17/04/2014 at 18:25, xxxxxxxx wrote:

    I hear ya. It definitely sucks.
    It's an annoying thing that Maxon did with their CA tools.
    I ran into this same issue a while ago with the CMotion object.

    -ScottA


Log in to reply