Hello all,
I want to iterate over all Itemtypes in a all Libraries but I get an Memory Exception in the second iteration in following Code:
try { ItemTypeLibraryPtr itemTypeLibrary = ItemTypeLibrary::FindByName(libName.c_str(), *ISessionMgr::GetActiveDgnFile()); for (ItemTypeLibrary::iterator iter = itemTypeLibrary->begin(); iter != itemTypeLibrary->end(); ++iter) { if (WString::IsNullOrEmpty(iter->GetName())) continue; auto name = iter-> GetName(); } } catch (...) { printf("Error\n"); }
The Exception appears when I try to retrieve the name or the internalName of the Item Type:
The Try - catch Block is not throwing aswell.
Am I using the iterator in wrong way or is there an alternative possibility to retrieve the Names of all Itemtypes in a library?
Thanks in advance
Manu
Hi Manuel Höger,
You will want to create to create your own list and push entries found into it, like this:
ItemTypeLibraryPtr lib = Bentley::DgnPlatform::ItemTypeLibrary::FindByName(libname, *dgnfile); list<WCharCP>* itemTypelist = new list<WCharCP>(); if (lib == nullptr) { return itemTypelist; } Bentley::DgnPlatform::ItemTypeLibrary::iterator i= lib->begin(); for (; i != lib->end (); i++) { itemTypelist->push_back(i->GetName()); } return itemTypelist;
HTH,Bob
Yes, thats the idea. Except that I use WStrings to copy the content of the WCharCP.
But the Error appears directly in the GetName() Method. The strange thing is that the error mostly appears at the second iteration. The first Name is extracted without problems.