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

    Hyperfiles and multiple plugin instances

    SDK Help
    0
    10
    829
    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 27/12/2016 at 03:14, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   14+ 
      Platform:   Windows  ;   Mac OSX  ; 
      Language(s) :     C++  ;

      ---------
      Hi,

      I am using Hyperfiles to store vector arrays in my object generator plugin. It works well for a single instance of the plugin, but when I have more than one instance of the plugin added to the scene, I don't know how to allocate the respective stored arrays to the respective instances of the plugin.

      Is there a certain routine that I need to follow?

      If code is needed I can post some code on how I am storing the vector arrays in the Read/Write/CopyTo.

      Thanks!

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

        On 28/12/2016 at 01:20, xxxxxxxx wrote:

        Hi,

        Each object instance is responsible to write/read/copy its own vector array.

        Yes, please post the code showing how you're storing the vector array in the object generator.

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

          On 28/12/2016 at 07:36, xxxxxxxx wrote:

          Thank you for your reply Yannik.

          In this simplified example, I have 2 vector arrays myVectorsA and myVectorsB, and an integer value that I am storing named myCount.

          Here is my Read/Write/CopyTo code:

          Bool myObject::Read(GeListNode *node, HyperFile *hf, LONG level)
          {
          	LONG stored_cnt = 0; 
          	hf->ReadLong(&stored_cnt);	
          	myVectorsA.Resize(stored_cnt);
            
          	LONG stored_cnt1 = 0; 
          	hf->ReadLong(&stored_cnt1);
          	myVectorsB.Resize(stored_cnt1);
            
            
          	if (level>=0)
          	{
          		for (LONG i=0; i<stored_cnt; i++) { hf->ReadLVector(&myVectorsA[i]); }
          		for (LONG i=0; i<stored_cnt1; i++) { hf->ReadLVector(&myVectorsB[i]); }
            
          		hf->ReadLong(&myCount);
          	}
            
          	return TRUE;
          }
            
          Bool myObject::Write(GeListNode *node, HyperFile *hf)
          {
          	hf->WriteLong(myVectorsA.GetCount());
          	hf->WriteLong(myVectorsB.GetCount());
            
          	for (LONG i=0; i<myVectorsA.GetCount(); i++)
          	{		
          		hf->WriteLVector(myVectorsA[i]);
          	}
          	for (LONG i=0; i<myVectorsB.GetCount(); i++)
          	{		
          		hf->WriteLVector(myVectorsB[i]);
          	}
          	
          	hf->WriteLong(myCount);
            
          	return TRUE;
          }
            
          Bool myObject::CopyTo(NodeData *dest, GeListNode *snode, GeListNode *dnode, COPYFLAGS flags, AliasTrans *trn)
          {
            
          	myObject* myObject= NULL;
          	myObject= static_cast<myObject*>(dest);
            
          	myObject->myVectorsA.CopyFrom(myVectorsA);
          	myObject->myVectorsB.CopyFrom(myVectorsB);
            
          	myObject->myCount= myCount;
            
          	return true;
          };
            
          
          

          Thanks

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

            On 28/12/2016 at 08:46, xxxxxxxx wrote:

            Thanks for posting the code.

            What are the members of your object generator class?

            In Read()/Write()/CopyTo() you only deal with the values of the current instance. So you just have to store/restore/copy the current instance values.

            Note the condition  level >=0 in Read() is useless as level should always be equal to 0 or higher.

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

              On 28/12/2016 at 11:21, xxxxxxxx wrote:

              The class members are myVectorsA, myVectorsB, myCount.

              After some reshuffling, I got it working with the above code.

              Thank you Yannick for taking the time to answer.

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

                On 28/12/2016 at 12:25, xxxxxxxx wrote:

                This really should be documented much better. It's very a convoluted system and not intuitive at all.
                I remember having a ton of trouble trying to figure it out when I was trying to store an array of BaseBitmap images for my PoseLibrary plugin. That was very frustrating and head banging thing to figure out.

                There really should be an example in the docs showing how to use arrays of class members with this system. The Vector type is a good choice. But the BaseBitmap type would be an even better example. Because you also need to free the memory for each image in the array.
                I remember that after I finally got the Read(), Write(), CopyTo() working. Then I had some trouble freeing the memory for the BaseBitmap instances in the array.

                Knowing how to use these three functions on a simple single variable is too basic. It doesn't help much when using arrays of things. Especially for types that have to have their memory allocated and freed.
                That really should be documented better.

                -ScottA

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

                  On 11/01/2017 at 07:42, xxxxxxxx wrote:

                  Hi Scott,
                  yes, we are aware, that the docs need to be improved here. And we are working on it. I added your specific question to our ToDo list.

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

                    On 11/01/2017 at 08:04, xxxxxxxx wrote:

                    Thanks Andreas.
                    BTW. You mentioned something quickly before Christmas about something big coming after the holidays.
                    Do you guys have a major document update or something in the works?
                    Or did I dream reading that? 😉

                    -ScottA

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

                      On 11/01/2017 at 08:37, xxxxxxxx wrote:

                      Hm, did I?
                      I'd be sorry, to have raised false expectations (and usually I really try to avoid such).
                      May be it was about docs on threading and UI? Then I have good news, today R18 SP2 got released and in parallel, we released an updated SDK documentation. In there are new manuals about these two topics. Just take a look under Overviews (or check out our latest blog post with direct links).

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

                        On 11/01/2017 at 09:10, xxxxxxxx wrote:

                        That must be it. I'm off to take a look at it now.
                        Thanks for the updates.

                        -ScottA

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