Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    XPresso: enable/disable user data

    Cinema 4D SDK
    3
    5
    1.5k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Passion3DP
      Passion3D
      last edited by

      Hi all

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

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @Passion3D
        last edited by ferdinand

        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

        1 Reply Last reply Reply Quote 1
        • Passion3DP
          Passion3D
          last edited by Passion3D

          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.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            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

            1 Reply Last reply Reply Quote 1
            • Passion3DP
              Passion3D
              last edited by

              Work fine 🙂
              Thanks a lot Manuel

              1 Reply Last reply Reply Quote 0
              • First post
                Last post