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

    add Userdata - incorrect

    Scheduled Pinned Locked Moved PYTHON Development
    12 Posts 0 Posters 1.1k 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 04/05/2015 at 22:08, xxxxxxxx wrote:

      Hello,

      I try to add User Data by getting from one Object and add them to an other.

      This Code run without error - but I need to open the User Data Manager to see the User Data in my Object.

      newuserdata = None 
          	if fix != None:
      	    	for id, bc in fix.GetUserDataContainer() :
      	    	    if id == foundid:
      	    	    	newuserdata = bc
      if newuserdata != None:
      	node = c4d.BaseObject(1030625)
      	node.SetName(newuserdata[c4d.DESC_NAME])
      	node.InsertUnder(opc)
      	doc.AddUndo(c4d.UNDOTYPE_NEW,node)
      	newud = node.AddUserData(newuserdata)
      	node[newud] = fix[foundid]
      	c4d.EventAdd()
        
      
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 06/05/2015 at 02:17, xxxxxxxx wrote:

        Hi,

        You can simply call c4d.gui.ActiveObjectManager_SetObject() with ACTIVEOBJECTMODE_OBJECT flag, the object and its new user data ID (pass 0 for flags parameter).

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

          On 06/05/2015 at 02:56, xxxxxxxx wrote:

          Hi Yannick,

          that not solve the problem - the user data is still not visible until i click into the user data manager

          Thanks

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

            On 06/05/2015 at 07:54, xxxxxxxx wrote:

            Hi,

            ActiveObjectManager_SetObject() should show the Object+User Data tabs in the attribute manager.
            Are you sure it is called with the complete added user data ID? A user data ID has a first level of ID ID_USERDATA then a second level with the ID beginning at 1.

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

              On 06/05/2015 at 15:53, xxxxxxxx wrote:

              i tried this

              newud = node.AddUserData(newuserdata)
              		   		node[newud] = fix[foundid]
              		   		 
              		   		c4d.gui.ActiveObjectManager_SetObject(c4d.ACTIVEOBJECTMODE_OBJECT,node,0,newud)
              
              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                On 06/05/2015 at 23:04, xxxxxxxx wrote:

                It seems ActiveObjectManager_SetObject() doesn't work well with child objects. You can simply call doc.SetActiveObject(node) instead.

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

                  On 07/05/2015 at 02:20, xxxxxxxx wrote:

                  Hi Yannick,

                  doc.SetActiveObject(node)  will select the object but it don`t change anything to the user data -  I need to open the User Data Manager to see the User Data in my Object.

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

                    On 07/05/2015 at 02:30, xxxxxxxx wrote:

                    Sorry, I had not read well your first post. I'm afraid there's no way to open the Manage User Data dialog.

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

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

                      There is no need if the user data will show up by adding them 🙂

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

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

                        Hi guys,

                        I was interested in this task, that´s why I decided to take part...

                        With this snippet you can port multiple userdata and it works as expected.
                        The if clause with the desc id depends on you, for sure.

                        One question; what kind of object is this : node = c4d.BaseObject(1030625) ?

                          
                        import c4d  
                        from c4d import gui  
                          
                          
                          
                        def main() :  
                          
                          newUserData = []  
                          
                          if op != None:  
                              userData = op.GetUserDataContainer()  
                              if userData!=[]:  
                                  for i in xrange(len(userData)) :  
                                      desc_id = userData[i][0]  
                                      if desc_id:  
                                          con = userData[i][1]  
                                          print i,desc_id,con  
                                          newUserData.append((desc_id,con))  
                          
                              if newUserData != None:  
                                  node = c4d.BaseObject(c4d.Onull)  
                                  node.InsertUnder(op)  
                                  doc.AddUndo(c4d.UNDOTYPE_NEW,node)  
                                  for i in xrange(len(newUserData)) :                 
                                      newud = node.AddUserData(newUserData[i][1])  
                                      node[newud] = op[newUserData[i][0]]  
                                    
                                  c4d.EventAdd()  
                                  doc.SetActiveObject(node)   
                                    
                        

                        Best wishes
                        Martin

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

                          On 14/05/2015 at 08:21, xxxxxxxx wrote:

                          Hey Martin,

                          thanks for the code - but even with that I see the same behavior - only after opening the user data dialog - i see the user data.

                          may the problem is not in this code - its in the object - the 1030625 is an own object.

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

                            On 14/05/2015 at 11:13, xxxxxxxx wrote:

                            Hello,

                            I'm a ghost without internet access and will not be able to reply back to you.
                            But there's a common problem with adding User Data that isn't documented.

                            If you create your UD gizmo. And it doesn't show up right way in the  AM.
                            Try usng this code at the end to force the AM to redraw itself. And show the new UD you added:

                            c4d.SendCoreMessage(c4d.COREMSG_CINEMA, c4d.BaseContainer(c4d.COREMSG_CINEMA_FORCE_AM_UPDATE))
                            

                            -The Ghost

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