cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

License delivery maintenance is planned for Saturday, July 26, between 12:00 and 20:00 CEST. During this time, you may experience outages or limited availability across our services, including BIMcloud SaaS, License Delivery, Graphisoft ID (for customer and company management), Graphisoft Store, and BIMx Web Viewer. More details…

Archicad C++ API
About Archicad add-on development using the C++ API.

[SOLVED] Guid array

Anonymous
Not applicable
for (GS::Array<API_Guid>::ConstIterator it = elements.Enumerate (); it != NULL; ++it) {   
         BNZeroMemory (&element, sizeof (API_Element));   
         element.header.guid = *it; 


I have specified witch guid to get. And i need to store them in array. I guess i'm doing something wrong.
When i use like this, Archicad crashes.:
API_Guid *arrayGuid  
arrayGuid=*it;
1 REPLY 1
Tibor Lorantfy
Graphisoft Alumni
Graphisoft Alumni
First you must allocate the memory for the array. There are several ways to do that, here is one for example:
// allocate memory for the array:
API_Guid** arrayGuid = (API_Guid**) BMAllocateHandle (elements.GetSize () * sizeof (API_Guid), ALLOCATE_CLEAR, 0);

// using the array:
(*arrayGuid) = (*it);

// when finished the work with the array don't forget to free the memory:
BMKillHandle ((GSHandle *) &arrayGuid);
Or if you don't want to bother with memory handling, then you should use GS::Array for this purpose:
GS::Array<API_Guid> arrayGuid;
arrayGuid.Push (*it);
// or insert it to a specific index:
arrayGuid.Insert (i, *it);

// you can get the pointer to the array content also:
API_Guid* arrayGuidPointer = arrayGuid.GetContent ();
arrayGuidPointer = (*it);