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

    Reading base link

    SDK Help
    0
    11
    916
    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
      Helper
      last edited by

      On 08/12/2014 at 05:27, xxxxxxxx wrote:

      It is possible on Read() that the linked object does not exist in the document yet due to ordering of creation in C4D so that method is untrustworthy.   I would also caution against using pointers (memory addresses) for storing data structures in file.

      You could add a LINK description to your object and the link is automatically saved and loaded with the plugin object (document file) instead.  C4D maintains the proper linked object reference.  If you want, the description element can be hidden from the A.M. interface (i.e.: HIDDEN keyword) so that the user does not see it.

      If the element must be dynamic, then GetDDescription() must be used and it gets trickier since now you must maintain a method to recreate the Link to the same object in the document (or in memory) each time.

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

        On 08/12/2014 at 05:58, xxxxxxxx wrote:

        Hello,

        as mentioned above the easiest way should be to save the BaseLink in the object's BaseContainer. To handle such links don't store a pointer to an object. Use the BaseLink[URL-REMOVED] class. This class offers the necessary ReadURL-REMOVED, WriteURL-REMOVED and CopyToURL-REMOVED methods.

        Best wishes,
        Sebastian


        [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

          On 10/12/2014 at 23:21, xxxxxxxx wrote:

          Hi Robert/Sebastian!

          Originally posted by xxxxxxxx

          If the element must be dynamic, then GetDDescription() must be used and it gets trickier since now you must maintain a method to recreate the Link to the same object in the document (or in memory) each time.

          I'm using a customgui plugin to do just this, and holding the references in a struct. I'm only using the link fields to grab the object. So once the object is grabbed, the link gui element is no longer needed, and is set to NULL and hidden (until the user needs the link again). This all appears to be working as expected - for instance I can do work on the referenced objects seemingly without any troubles.

          Originally posted by xxxxxxxx

          To handle such links don't store a pointer to an object. Use the BaseLink[URL-REMOVED] class. This class offers the necessary ReadURL-REMOVED, WriteURL-REMOVED and CopyToURL-REMOVED methods

          I've tried using BaseList2D/BaseLink/C4DAtom and saving a baselink into the obj->GetDataInstance() basecontainer, but all are returning null objects when I reload/open the scene file. So I don't know if that means there's something in my code causing the problem, but reading past topics, others appear to of had the same problem and have commented that the possible cause is that the objects you're trying to link to don't exist in the scene document yet (which Robert eluded too above). I feel a bit confused with this one. There doesn't seem to be a clear working guide to go with.
           
          WP.


          [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

            On 11/12/2014 at 02:25, xxxxxxxx wrote:

            Hello,

            Originally posted by xxxxxxxx

            I'm using a customgui plugin to do just this, and holding the references in a struct. I'm only using the link fields to grab the object. So once the object is grabbed, the link gui element is no longer needed, and is set to NULL and hidden (until the user needs the link again).

            this sound a little weird to me. When you are hiding the linkbox anyway I would not set it to null. Instead I would keep using the linkbox to get the linked object when I need to work with it. Without knowing more of your code I can't tell much more.

            Best wishes,
            Sebastian

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

              On 11/12/2014 at 20:38, xxxxxxxx wrote:

              The problem I've found with that though Sebastian is that I can't set link fields with objects that my object plugin owns. My plugin holds links to a mix of both scene document objects and internal objects. On top of this, each indexed container can have any number of versions of the object in question. For example, 5 links whom each hold 5 versions requires 25 references, but there can only ever be 5 objects 'in use' at any one time.
               
              So to keep consistency across the board, I simply don't use the link field, other than to catch the drag and dropped object. The link field is hidden and an edit text field is shown instead, which I set with the name of the object that that particular index is using. That side of the plugin seems to work well.
               
              It would make more sense if I showed you the object/plugin itself, but I can't do that until the reading and writing of the object references work - otherwise I can't pass an example scene file where you can see it working! 🙂
               
              WP.

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

                On 12/12/2014 at 01:36, xxxxxxxx wrote:

                Hello,

                as I said, I wouldn't store BaseObjects directly but use BaseLink object's. So when you get the object from a LinkBox you can put it into a BaseLink and use that BaseLink to access this object later. For objects that are not part of a document you may need to use ForceGetLink()[URL-REMOVED].

                Maybe you should handle a own BaseDocument that stores your "owend" objects. But these are just some ideas based on what you tell. Without any code it's hard so say anything.

                Best wishes,
                Sebastian


                [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

                  On 19/12/2014 at 09:38, xxxxxxxx wrote:

                  Hello WickedP,

                  was your question answered?

                  best wishes,
                  Sebastian

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

                    On 20/12/2014 at 17:32, xxxxxxxx wrote:

                    Hi Sebastian,

                    I'm making a few changes to some of the guts of the plugin in the hope to finish off the working side of it. Might then be able to post the plugin itself (or a link to a download/video) so you can see what the plugin is and the idea of what the plugin does (and what it needs!). Bare with me for a little more, will see if I can get this done for sometime this week.

                    WP.

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

                      On 15/01/2015 at 01:25, xxxxxxxx wrote:

                      Hi Sebastian,

                      my apologies for not getting back to this one sooner. I've had a life curve ball thrown at me and I'm needing to spend some time sorting out other things which have taken priority.

                      If you're wanting to close/archive this topic, I can start a new one when I'm able to step back into it again.

                      Kind regards,

                      WP.

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

                        On 16/01/2015 at 09:51, xxxxxxxx wrote:

                        Hello,

                        I hope everything will be alright. We will close this thread and we are happy to help you when you work on this again.

                        best wishes,
                        Sebastian

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