cancel
Showing results for 
Search instead for 
Did you mean: 
EN
cancel
Showing results for 
Search instead for 
Did you mean: 
Newbie
Participant

How to copy element without click event?

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);
}
=================
1 Reply 1

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

Automating Archicad with Add-Ons, GDL-Objects & Python Archi-XT.com

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!