Access the Limit Min/Max in the User Data Manager



  • Hi,

    Is there a way to modify the limit min/max in the User Data Manager?
    With this page as a reference, I am unable to access the limit min/max.

    I initially thought it is [c4d.DESC_MINEX] and [c4d.DESC_MAXEX] since they require boole values. But they don't work as expected.

    You can see an illustration file here:
    https://www.dropbox.com/s/6xez5y1rd9qm2vz/c4d093_Limit_Min_Max_Python.jpg?dl=0

    Is there a way around this?

    Thank you for looking at the problem.



  • Hi @bentraje DESC_MAXEX is only used for the live editing in the GeDialog. And in fact, the Checkbox for Limit Min/Max is only stored and used in the UI. After that, it defines the MIN value either to the entered value or either by the default min/max value the datatype can handle.
    So through the API, there is no way to check/uncheck the limit of a UserData in the dialog since they are only managed by the Dialog and since UserData value is always limited (a float have a limit, same for an int... etc)

    So you can enable limit by restore theses default value like so. (Of course, as said before it will not change the enable state of the Limit in the UserData Manager)

    import c4d
    
    
    def main():
        for id, bc in op.GetUserDataContainer():
            print bc[c4d.DESC_MIN]
            
            # The datatype of the user data is the last part of the DescID,
            dataType = c4d.GetCustomDataTypeDefault(id[-1].dtype)
            
            # Defines the min value of the description container with the default min value of the datatype
            bc[c4d.DESC_MIN] = dataType[c4d.DESC_MIN]
            
            # Sets the User Data new Description
            op.SetUserDataContainer(id, bc)
            print bc[c4d.DESC_MIN]
            
            c4d.EventAdd()
    
    if __name__=='__main__':
        main()
    

    If you have any questions, please let me know.
    Cheers,
    Maxime.



  • @m_adam
    Apologies for the late response.

    Can I confirm you response:
    So, it's not possible to access the Limit Min/Max in the User Data Manager through script but its possible through plug-in (GeDialog)?

    Sorry not really sure about the GeDialog since I have little to no knowledge about it.

    RE: So you can enable limit by restore theses default value like so.
    I'm not sure we are on the same page. I want the min and max but only through the slider interface. So if the user wants to type something beyond the slider amount, he can freely do so. I guess that's what the Limit Min/Max is far.
    Correct me if I'm wrong.

    Thanks



  • Hi @bentraje, there are 4 things regarding limit.

    1. A Checkbox (Limit Min/Max) to enable/disable the overall limit of a datatype.
    2. An Input to enter the value of the limit of the datatype.
    3. In some case a Checkbox (Slider Min/Max) to enable disable the limit of the slider used in the UI.
    4. An Input to enter the value of the slider limit for this datatype.

    But let's consider a float. A float have a value range between -1e+20 and 1e+20. So, in any case, the value will have a limit which is this one.
    The First Checkbox will simply set this limit to the value entered in input 2, while if you uncheck it the dialog restore it at -1e+20 and 1e+20.
    So this Checkbox is only something used in the User Data Manager Gedialog in order to have a user-friendly interface, but that's it you can't control it since this checkbox is stored nowhere else than the User Data Manager.

    Same things apply for my point 3 and 4.
    In conclusion, you can't drive the enable/disable status of the limit checkbox since this is fully handled by the User Data Manager GeDialog, but you can simulate what this dialog does.

    Hope it's more clear, if you have any questions, please let me know.
    Cheers,
    Maxime.



  • @m_adam said in Access the Limit Min/Max in the User Data Manager:

    In conclusion, you can't drive the enable/disable status of the limit checkbox since this is fully handled by the User Data Manager GeDialog, but you can simulate what this dialog does.

    Still a bit over my head but thanks for the clarification.
    So the code pointed above is to simulate what the dialog function.


Log in to reply