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

    [SOLVED]Generator GetSettingsInstance

    SDK Help
    0
    3
    598
    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 06/12/2017 at 14:54, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:    
      Platform:      
      Language(s) :

      ---------
      I'm currently doing a generator. In GetVirtualObjects I create another document in memory, and I would like to get/set data from this tempo doc.
      So I used

      BaseObject* MainObjectData::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh)
      {
      	BaseObject* objDown = op->GetDown();
      	if (!objDown)
      		return nullptr;
        
      	objDown = static_cast<BaseObject*>(objDown->GetClone(COPYFLAGS_0, nullptr));
        
      	BaseDocument* copyDoc = BaseDocument::Alloc();
      	if (!copyDoc)
      		return nullptr;
        
      	BaseObject* nullMaster = BaseObject::Alloc(Onull);
      	if (!nullMaster)
      		return nullptr;
        
      	copyDoc->InsertObject(nullMaster, nullptr, nullptr);
      	objDown->InsertUnder(nullMaster);
        
      	// I know doc point to the same object of nullmaster
      	// But in my plugin I get informations from another function and use GetDocument, So I do it in my example.
      	BaseDocument* doc = objDown->GetDocument();
      	if (!doc)
      		return nullptr;
        
      	// Always return me nullptr why?
      	BaseContainer* bc = doc->GetSettingsInstance(DOCUMENTSETTINGS_GENERAL);
      	if (!bc)
      		return nullptr;
        
      	BaseObject::Free(nullMaster);
      	BaseDocument::Free(copyDoc);
        
      	BaseObject* cube = BaseObject::Alloc(Ocube);
      	return cube;
      }
      

      it's return a nullptr.

      This also fails

      	BaseContainer* bc = doc->GetDataInstance();
      	if (!bc)
      		return nullptr;
      	bc = bc->GetContainerInstance(DOCUMENTSETTINGS_GENERAL);
      	if (!bc)
      		return nullptr;
      

      While for different type it's work fine

       doc->GetSettingsInstance(DOCUMENTSETTINGS_DOCUMENT);
      

      Thanks in advance

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

        On 07/12/2017 at 02:13, xxxxxxxx wrote:

        Hi,

        this actually has nothing to do with the use inside of a ObjectData plugin.
        DOCUMENTSETTINGS_GENERAL simply can not be retrieved via GetSettingsInstance(), but only via BaseDocument::GetData().
        In the BaseDocument manual this gets mentioned. We'll add this information to the API references, too (by the way, the BaseDocument::GetData() link in the manual currently links to BaseList2D::GetData(), this will be fixed as well).

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

          On 07/12/2017 at 03:13, xxxxxxxx wrote:

          Not sure to understand the pattern decision made behind of this (a function that could fail if a specific parameter is given, while parameter are from the same enum)
          But it's work !

          Thanks.

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