[SOLVED]Generator GetSettingsInstance

  • On 06/12/2017 at 14:54, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:    
    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);
    	// 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* 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


    Thanks in advance

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


    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).

  • 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 !


Log in to reply