Solved XPresso: enable/disable user data

Hi all

Is it possible to deactivate user data or a tab from xpresso?

Hi,

@Passion3D said in XPresso: enable/disable user data:

Is it possible to deactivate user data or a tab from xpresso?

  1. Using a Xpresso Python node, you can do anything a Python script could do.
  2. Modifying the GUI of a node means modifying its description in Cinema. You should take a look at Descriptions. Note that Cinema will not evaluate all description fields for all node attribute types and also will ignore/overwrite some fields in the case of user data descriptions. Depending on what you do mean by "deactivate", the description fields DESC_HIDE and DESC_EDITABLE might be what you are looking for.
  3. But you cannot modify the description of a node in a scripting environment, which rules out deactivating "a tab", but you can modify the user data description with BaseList2D.GetUserDataContainer and .SetUserDataContainer.

Cheers,
zipit

MAXON SDK Specialist
developers.maxon.net

Here's the test I took. By putting my script in a python tag on my object, it works. But in an xpresso python node, nothing happens.
Test.c4d

If you delete the tag, keeping only the xpresso node, it doesn't work.

hi,

you almost have everything. You could simply create some port to ease your life. Here, I've added an input port for the object, a bool and an integer. Output port is replaced by a bool.

727d8bed-5be3-48a8-b76f-b0872a2c02e3-image.png

you can use GetDepth to be sure you can access a subdescid or your code could stop working.

You don't need the two "If" you can simply pass the value of the flag. (or in this case the inverse)
I'm not using the ouput port here. But you should.

import c4d
def main():
    global Output1
    Output1 = True
    h1 = obj.GetUserDataContainer()
    for descID, container in h1:
        if descID.GetDepth() < 2:
            continue
        if descID[1].id == UserDataID:
            container[c4d.DESC_HIDE] = not Flag
            obj.SetUserDataContainer(descID,container)
        

Cheers,
Manuel

MAXON SDK Specialist

MAXON Registered Developer

Work fine 🙂
Thanks a lot Manuel