Hello @thomasb,
thank you for reaching out to us. Please remember to open a new thread for new questions of yours. It is fine to ask follow-up questions in a topic, but when the threshold to a new topic is being crossed, a new thread should be opened. I have done this for you here.
In principle this is at least partially possible. You can determine the visibility for a user data description element with the description field DESC_HIDE
, see example at the end of the posting for details. It is not possible to gray-out, i.e., disable, user data description elements. It is also a bit a case of an unusual workflow for user data, since you would have to rebuild the user data container every time you want to hide or show and element in it. You could overwrite for example message()
in a Python scripting tag and then react to when a user clicks a button, drags a slider, etc. in the user data and rebuild the user data based on that. Which would give you the dynamic GUI feeling you are probably after. I have done this in the past, but more as a hack for fun to see how far I can push user data. I would not recommend doing it as it will complicate things like animation and can lead to "janky" interfaces. Being bound to the execution order of expressions can also lead to problems.
If you want dynamic GUIs, you should implement a plugin. There you can overwrite NodeData.GetDDescription()
to modify the description, e.g., add, remove, or hide stuff. To disable stuff, i.e., gray it out, you must overwrite NodeData.GetDEnabling()
.
Cheers,
Ferdinand
"""Example for adding a hidden user data element.
"""
import c4d
def main():
"""Adds a hidden check box and a visible integer element to the user
data of the selected object.
"""
if op is None:
raise ArgumentError("Please select an object for running this script.")
datenDesc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_BOOL)
datenDesc[c4d.DESC_NAME] = "Daten"
datenDesc[c4d.DESC_HIDE] = True # Element will be hidden
stepsDesc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_LONG)
stepsDesc[c4d.DESC_NAME] = "steps"
stepsDesc[c4d.DESC_HIDE] = False # Element will be visible
op.AddUserData(datenDesc)
op.AddUserData(stepsDesc)
c4d.EventAdd()
if __name__ == '__main__':
main()