Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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
    • Recent
    • Tags
    • Users
    • Login

    fill quicktab in userdata

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 497 Views
    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.
    • H Offline
      Helper
      last edited by

      On 06/05/2015 at 09:38, xxxxxxxx wrote:

      Hello there,

      I am trying to modify existing quicktab radio buttons in userdata with Python.
      Example: There is a varying number of objects in a parent. The number of tabs in the quicktab should correspond to the number of children and the captions should at least show their index/number of the child .

      I 'm familiar with the basics of getting and setting userdata, appending items to lists, etc. Have been trying hard to do this for quite a while and any hint is greatly appreciated.

      Wolf

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 07/05/2015 at 00:12, xxxxxxxx wrote:

        Hi,

        To fill the cycle options for the quick tab user data you need to retrieve its description container and change DESC_CYCLE entry. It is a container with the entry integer value and string caption:

        data = op.GetUserDataContainer()
          
        # Get user data description id and data container
        descid = data[0][0]
        bc = data[0][1]
          
        # Build new cycle options container
        cycle = c4d.BaseContainer()
        cycle[0] = "Tab 1"
        cycle[1] = "Tab 2"
        cycle[2] = "Tab 3"
        cycle[3] = "Tab 4"
        cycle[4] = "Tab 5"
        bc[c4d.DESC_CYCLE] = cycle
          
        # Set modified description data container
        op.SetUserDataContainer(descid, bc)
          
        # Notify Cinema 4D for changes
        c4d.EventAdd()
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 07/05/2015 at 03:16, xxxxxxxx wrote:

          Thank you Yannick!!!

          I am having a hard time understanding that description id stuff. It's about items in the baselist containers, I know. Just can't REALLY figure it out from the SDK, so far. Can you give me a hint, where I find a comprehensive explanation?

          Anyway - your help is much appreciated and I will keep learning.

          Cheers, Wolf

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 07/05/2015 at 07:23, xxxxxxxx wrote:

            Quicktab dynamically filled:

            Got it to work and thought, I share...
            I call this as a user script and not inside a Python tag since the number of children does not change often during projects. I'll eventually use a button and the message() function in the userdata but that seems to be too much of a distraction here.

            Thanks again for the input.

            ----------------------------------------------------

            import c4d
            from c4d import gui
              
            def setQuickTab(obj, data) :
              
                descid = data[0][0]
                bc = data[0][1]
                
                # Build new cycle options container static
                #cycle = c4d.BaseContainer()
                #cycle[0] = "Tab 1"
                #cycle[1] = "Tab 2"
                #cycle[2] = "Tab 3"
                #cycle[3] = "Tab 4"
                #cycle[4] = "Tab 5"
                
                # Get the number of child objects
                parent = doc.SearchObject("UD container") # could be any different object
                count = len(parent.GetChildren())
                print "count: ", count
                
                
                # Build new cycle options container dynamically
                cycle = c4d.BaseContainer()
                
                for i in range (0,count) :
                    caption = "child " + str(i+1)
                    cycle.SetData(i, caption)
                
                bc[c4d.DESC_CYCLE] = cycle
              
                # Set modified description data container
                obj.SetUserDataContainer(descid, bc)
                
                # Notify Cinema 4D for changes
                c4d.EventAdd()
                
            def main() :
                obj = doc.SearchObject("UD container")
                data = obj.GetUserDataContainer()
                setQuickTab(obj, data)
              
            if __name__=='__main__':
                main()
              
            
            
            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 07/05/2015 at 07:42, xxxxxxxx wrote:

              Thanks for sharing your final working script.

              A parameter description or user data description container for objects holds all the information for the display of these parameters in the Attribute Manager. The IDs of the entries in this description container are defined in DESC values.

              Python currently only supports the modification of user data description with BaseList2D.GetUserDataContainer()/BaseList2D.SetUserDataContainer().
              And it returns a read-only Description object for a base list allowing to browse through all of its parameters.

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