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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    How to get to the str-value in a UserData Integer Cycle

    Cinema 4D SDK
    python
    2
    4
    1.2k
    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.
    • S
      SteveJLV
      last edited by

      To get the USERDATA from op we simply use, for instance: op[c4d.ID_USERDATA,7]
      this will give us the value from the chosen option index (7) in my USERDATA
      Data Type : Integer, Interface : Cycle

      To get to the 'str' value which corresponds to this Option I constructed the following code:
      op.GetUserDataContainer()[8][c4d.DESC_NAME].GetContainer(c4d.DESC_CYCLE).GetString(op[c4d.ID_USERDATA,7])
      🤔
      it works but this seems to me like a little overkill (understatement)
      Is there a better/ correct way to get to the 'str'-value. Also I have to know the position in the GetUserDataContainer() (in my case [8]) to get to the value.

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        as always, please post questions regarding the Cinema 4D APIs in the "Cinema 4D Development" subforum. Please also use the Q&A system.

        Do you mean with 'str' value the label of the option?

        GetUserDataContainer() allows to browse through all user data description containers. These contains contain information on the settings of the user data parameters. Information on the cycle interface is stored under c4d.DESC_CYCLE which returns a BaseContainer with the information. This can look like this:

        # user data parameter with the ID 1
        ID = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER,0), c4d.DescLevel(1))
        
        # get all user data parameter descriptions
        for id, bc in op.GetUserDataContainer():
            
            # check for ID 1
            if id == ID:
                
                # print parameter name
                print("Parameter Name: " + bc.GetString(c4d.DESC_NAME))
                
                # get cycle settings
                cycleBC = bc.GetContainer(c4d.DESC_CYCLE)
        
                # print cycle data
                for element in cycleBC:
                    print("Option: " + str(element[0]))
                    print("Label: " + str(element[1]))
        

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        S 1 Reply Last reply Reply Quote 2
        • S
          SteveJLV @s_bach
          last edited by

          @s_bach Thanks for your reply, So I guess there is no 'easy' way to get the label value.
          I was working in a Python Generator's Object code and so filed my question under Python, my bad.
          I'll try to get it right with my next question. 😳
          and yes I meant this one:0_1552497629402_UserData.PNG

          S 1 Reply Last reply Reply Quote 0
          • S
            SteveJLV @SteveJLV
            last edited by

            @stevejlv I found a workaround: the value part in the value;string Cycle option list does not have to be 0,1,2 etc.
            So I can give them the exact value as the string part (as long as they are int) and get the value I want the old fashioned way: [c4d.ID_USERDATA,1]

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