2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations
2023-09-10
06:38 AM
- last edited on
2023-09-12
09:13 PM
by
Laszlo Nagy
Below is sample code from AC Element Test, Is there anyone know could it possible to copy an element without click event by looping thru all select element's guid instead?
=================
void Do_CopyElem (void)
{
API_Element element = {};
API_ElementMemo memo = {};
GSErrCode err;
API_ElemType type;
API_Guid guid;
if (!ClickAnElem ("Click an element", API_ZombieElemID, nullptr, &type, &guid)) {
WriteReport_Alert ("No element was clicked");
return;
}
element.header.type = type;
element.header.guid = guid;
err = ACAPI_Element_Get (&element);
if (err == NoError)
err = ACAPI_Element_GetMemo (element.header.guid, &memo);
if (err != NoError) {
ErrorBeep ("ACAPI_Element_Get/Memo", err);
return;
}
if (err == NoError) {
element.header.floorInd ++;
err = ACAPI_Element_Create (&element, &memo);
if (err != NoError)
ErrorBeep ("ACAPI_Element_Create", err);
}
// ---- consistency check
if (err == NoError)
CompareElems (element, memo);
// ----
ACAPI_DisposeElemMemoHdls (&memo);
}
=================
2023-09-30 09:40 AM
Hi,
Yes you should take a look at ACAPI_ElementList_GetList for that. Use API_ZombieElemID
if you want to get elements of all types. Something like this:
GS::Array<API_Guid> allElements;
ACAPI_Element_GetElemList (API_ZombieElemID, &allElements);
for (auto elemGuid : allElements) {
// Do your stuff here
}
Hope that helps!
Bernd