[AECOsim V8i SS6 C++ TriForma] Adding a DataGroup[DG] to an existing element leads to Access Violation.

There are still a lot of V8 installation in the world, so I would like to extend some Elements with DG in V8. There is a sample “DGExamples” of low quality (unused functions, magic texts, link issues, etc.) as documentation. After reading and understanding (hopefully) the core of this sample, I got these few lines to add something to an existing element:

if (SUCCESS == mdlAssoc_getElementDescr(NULL, &ulFilePos, ullSchaleElmId, pModelRef, TRUE))
   ElementRef ElmRef = mdlModelRef_getElementRef(pModelRefReal, ulFilePos);

   if (NULL != ElmRef)
      Bentley::Building::Elements::BuildingEditElemHandle beeh(ElmRef, pModelRef);
      std::wstring _catalogTypeName;
      std::wstring _catalogInstanceName;

      _catalogTypeName = L"Door";
      _catalogInstanceName = L"x_Single Flush Panel";

      beeh.GetCatalogCollection().InsertDataGroupCatalogInstance(_catalogTypeName, _catalogInstanceName);

      //std::wstring const itemXPath = L"Door/Door/@DoorMaterial";
      //std::wstring const itemValue = L"Wood";
      //CCatalogSchemaItemT* pSchemaItem = NULL;
      //if (NULL != (pSchemaItem = beeh.GetCatalogCollection().FindDataGroupSchemaItem(itemXPath)))
      //   pSchemaItem->SetValue(itemValue);

      nRetErfolg = beeh.Rewrite();;

This is just to test, and yes, ElementHandle and ModelRefP are valid, and I know, I uses magic-text, too Blush

Beeh seems to contain something, and beeh.GetCatalogCollection() does not return NULL or something funny.

But InsertDataGroupCatalogInstance() will throw a really heave exception with memory violation at 0x05.

Seems there is missing some initialization, but I did not find something in the help or sample.

What could I do?

Parents Reply Children
No Data