Weight Manager Window access help



  • I want to use python to control the weight manager that is already open. For example, the mode switch Smooth ---Add, call button(apply selected), etc., I try to get information in the script log, but it does not seem to work, the following is my code:

    tool = plugins.FindPlugin(1025028)
    tool[c4d.ID_CA_WEIGHT_MGR_WEIGHT_MODE] = 2  
    tool[c4d.ID_CA_WEIGHT_MGR_WEIGHT_STRENGTH] = 0.5
    c4d.CallButton(tool,c4d.ID_CA_WEIGHT_MGR_APPLY_SELECTED)
    

    When I drag and drop a weight manger window parameter into the console, I can get a variable WeightManager. I can access and modify the weight manger window parameter through this variable. How can I get this variable through python? As shown below
    test.png

    Thanks for any help!



  • Hello,

    You are talking about the Weight Manager (the dialog box), not a tool ?

    did you had a look at this thread ?
    As a static class, you can use every function directly.

    the documentation

    Cheers,
    Manuel



  • @m_magalhaes Thanks,Solved my problem!

    But I still have some doubts and hope to be solved.

    • 1: Why drag a weight manager Dialog parameter to the console, the resulting WeightManager is a BaseList2D
    • 2: Is there a way to access the opened Dialog and modify its parameters (such as modifying values, CallButton, etc.)


  • @chuanzhen said in Weight Manager Window access help:

    But I still have some doubts and hope to be solved.

    • 1: Why drag a weight manager Dialog parameter to the console, the resulting WeightManager is a BaseList2D
    • 2: Is there a way to access the opened Dialog and modify its parameters (such as modifying values, CallButton, etc.)

    Hi,

    this is pure speculation, but if you dig around a little:

    import c4d
    from c4d import plugins
    
    def main():
        plugin_ids, op = [], plugins.GetFirstPlugin()
        while op:
            if "Weight Manager" in str(op):
                if op.GetID() not in plugin_ids:
                    plugin_ids.append(op.GetID())
            op = op.GetNext()
        print "plugin_ids:", plugin_ids
        
        for pid in plugin_ids:
            op = plugins.FindPlugin(pid)
            print "-" * 79
            print op   
            for cid, value in op.GetData():
                print cid, value
            print op.GetChildren()   
    
    if __name__=='__main__':
        main()
    

    you will find out, that there are actually two weight manager plugin ids and both of them have nothing (meaningful) attached to them, what we could access:

    plugin_ids: [1026919, 1025028]
    -------------------------------------------------------------------------------
    <c4d.plugins.BasePlugin object called 'Weight Manager' with ID 11 at 0x0000017F4D957070>
    5102 0
    []
    -------------------------------------------------------------------------------
    <c4d.plugins.BasePlugin object called 'Weight Manager' with ID 4 at 0x0000017F4D957DB0>
    5102 0
    []
    

    So your approach was correct, but the Weight Manager is just a special case. One hint should be that it has its own window, but yet you can treat it like a description resource and drag and drop stuff into the command line. My guess would be that one of the plugins spawns a GeDialog which contains a DescriptionCustomGui which then is set to some BaseList2D unknown to us, which holds the actual gui/description.

    Cheers
    zipit



  • @chuanzhen said in Weight Manager Window access help:

    1: Why drag a weight manager Dialog parameter to the console, the resulting WeightManager is a BaseList2D
    2: Is there a way to access the opened Dialog and modify its parameters (such as modifying values, CallButton, etc.)

    The dialog box doesn't store the values; it's done somewhere else. Just like the SnapSettings or the ModelingSettings.
    That's why you retrieve a BaseList2D.

    But the point is that we have an API to access those parameters and commands. The weight manager is just a UI calling the same functions.

    As i pointed, you also have the c++ manual and the documentation

    You have GetParameter, SetParameter, all function to apply weight and thing like that.

    Do you have anything you can't do with the API ? (maybe we could add it)

    Any other way to retrieve parameter should be considered as a "hack". I'm not saying hacks are bad, but they are, if there's an API that does the job.

    On the thread I linked, you have this example :

    c4d.modules.character.CAWeightMgr.SetParameter(doc, c4d.ID_CA_WEIGHT_MGR_ENABLE_DISPLAY, True)
    

    if you want to retrieve the mode of the Commands :

    c4d.modules.character.CAWeightMgr.GetParameter(doc, c4d.ID_CA_WEIGHT_MGR_WEIGHT_MODE)
    

    As I said, it's a static class that will know where to go, in order to retrieve the datas.

    Once again, if there's something you can't do with the api let us know, maybe i missed a point here.

    Cheers,
    Manuel



  • @m_magalhaes Thanks for your careful answer.
    This problem appeared in my mind. My first ideal solution was to control some of the Dialog UI through python. I immediately went to plugin cafe to search for the answer. In fact, I saw the thread.But because of my wrong first ideal solution, I didn't read the article carefully.
    I have to read the documentation carefully.😀



  • @zipit Thanks for showing me so much detail.😁


Log in to reply