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

    Special Options - creating UserData with Python

    Scheduled Pinned Locked Moved PYTHON Development
    14 Posts 0 Posters 1.6k 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 19/06/2013 at 12:03, xxxxxxxx wrote:

      @ scott using plain ids is not a good advice imho. also your code example is very
      cppish imho, no offense.

      @ op your fault seemed to be that you did not pass the id properly.

      import c4d
          from c4d import gui
          #Welcome to the world of Python
          
          def main() :
              if op:
                  nextID = len(op.GetUserDataContainer()) - 1
                  bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_STRING)
                  bc[c4d.DESC_NAME] = 'Static string'
                  bc[c4d.DESC_CUSTOMGUI] = c4d.CUSTOMGUI_STATICTEXT
                  op.SetUserDataContainer([c4d.ID_USERDATA, nextID], bc)
                  c4d.EventAdd()
                  
          if __name__=='__main__':
              main()
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 19/06/2013 at 13:22, xxxxxxxx wrote:

        hello,

        absolute great! thanks a lot! the problem with the special type is working great ๐Ÿ™‚

        The only thing remaining is the problem with the default open group ๐Ÿ˜ž
        Do you maybe have an other idea how to solve it?

        bc[c4d.DESC_GUIOPEN] = True
        

        does not work ๐Ÿ˜ž

        greetings,
        Christopher

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

          On 19/06/2013 at 14:15, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          @ scott using plain ids is not a good advice imho. also your code example is very
          cppish imho, no offense.

          Actually. I do take offense to that comment. Because I also showed how to write it with text based descriptions. And I even went as far putting a comment that it's the Maxon recommended way.
          So I can't think of any reason why you would even bring that up.ย  Other than personal reasons.

          And as for your cppish remark.
          IMO. It's very important to understand how UD works. And that requires seeing the containers in their raw form without any python covering them up.
          Once you know how the containers work. Then the users can write code in a more pythonic manner if they wish. But they need to know how it works first.

          -ScottA

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

            On 19/06/2013 at 14:48, xxxxxxxx wrote:

            yea, you are absolutly right! the main issue is, to understand the tools and objects, that are used!
            It is much better then just to get the solution without understanding, what is happening there.

            But still, in my case the command (two posts aboph) is not working ๐Ÿ˜ž

            greetings,
            Chriss

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

              On 19/06/2013 at 16:36, xxxxxxxx wrote:

              Originally posted by xxxxxxxx

              yea, you are absolutly right! the main issue is, to understand the tools and objects, that are used!
              It is much better then just to get the solution without understanding, what is happening there.

              But still, in my case the command (two posts aboph) is not working ๐Ÿ˜ž

              greetings,
              Chriss

              yeah, now that you wrote it ... the OPEN flag in descriptions is used to toggle the state ofย 
              things like color fields or spline guis. Groups are set with DEFAULT 0|1. So my guess was kind
              of pretty wrong ๐Ÿ˜‰ You might want to try your luck with the ID for the default value.

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

                On 19/06/2013 at 19:30, xxxxxxxx wrote:

                If you are referring to the "Default Open" option for UD groups.

                The ID for that one isn't: c4d.DESC_GUIOPEN
                It's: c4d.DESC_DEFAULT

                -ScottA

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

                  On 24/06/2013 at 15:31, xxxxxxxx wrote:

                  you are all my absolute heroes. Thanks a lot!
                  Everything is now working just fine ... most of the tings ๐Ÿ˜›
                  Only one last little question:

                  the command

                  bc[c4d.DESC_COLUMNS] = 3
                  

                  does not change the amount of colums in a group.
                  Because of that, I searched a littlebit in this board and came up with this solution:

                  bc[22] = 3
                  

                  it is now working! My group now has tree columns.
                  But I wondered, what command is behind the "22"?
                  is there a other way to write the "bc[22]"? maybe something like "bc[DESC_xxxxxx]"?

                  greetings,
                  Chriss

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

                    On 24/06/2013 at 15:59, xxxxxxxx wrote:

                    I don'tย  know if this was a typo on your part. But you forgot the c4d. prefix in your DESC_COLUMNS example.
                    But it's possible that it doesn't work even with the c4d prefix(I haven't tested it myself to see).
                    There are still some things that have not been linked to a text based symbol ID# yet.ย  And you'll have no choice but to use the numeric ID#.

                    Most of the UD ID#s can be found in the file: C:\Program Files\MAXON\CINEMA 4D R13\resource\_api\c4d_libs\lib_description.h

                    In that file. There is an entry:ย  DESC_COLUMNS = 22
                    If Sebastien hasn't linked the text based name to that ID number. Then you'll have to use the actual number until he sets it up to use the text based ID's.

                    -ScottA

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

                      On 24/06/2013 at 16:48, xxxxxxxx wrote:

                      hey,

                      thanks a lot for the fast reply!
                      And yes, you are right, I forgot the "c4d." in front of the tag^^
                      This can happen if you write the code without copy&past ๐Ÿ˜›

                      The interesting fact here is, that the id 22 seems to be linked to "DESC_COLUMNS" but will not work. maybe it is more a bug, then a missing connection. But whatever the case is, it only works with the id.
                      But thanks also for the c++ header file. this one was new to me, so now I know where you guys get all the text based sybols ๐Ÿ˜›

                      But in this case I have an other little question:

                      I found this userdata in an project and thought this is very interesting, because there is no actual data type and this is only a kind of "dummy" in order to seperate two userdatas.
                      So two of this userdatas can make a "space"/"gap" in a group in order to sort the things a little better.
                      _<_img src="http://weltderpixel.com/dd/c4d board.jpg" border="0" /_>_

                      But how can I create such an userdata with python?
                      And how can I create it without python?

                      I have really no idea how to create this userdata. Not with the normal c4d method and also not with python. Maybe someone can help me with this one.
                      It would be really nice!

                      greetings,
                      Chriss

                      [EDIT] ah, sry, I now see that the image is not 100% in english. But I think, that you all know, what the names stand for ๐Ÿ˜› ... and if not, then tell me and I will change it!

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

                        On 24/06/2013 at 17:05, xxxxxxxx wrote:

                        The only time I've seen something like that is when I accidentally created a UD entry with an ID# of zero.
                        UserData entries are supposed to start at 1. And C4D doesn't like it when a zero ID is used.
                        But since the ID# is 30 in your example. I can't really say what's going on in that one.

                        UserData is basically a tree with invisible branches. And the actual UD gizmos themselves are like leaves on the branches.
                        Using things like PopId() & PushId() you can build a UserData tree with empty branches in it that don't have a UD gizmo on it/them. And this can possibly be used to do some special tricks like what you're got there.

                        -ScottA

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