We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2024-05-04 08:27 PM - last edited on 2024-09-17 11:04 AM by Doreena Deng
Hello,
I am trying to delete the Hotlink Element via API using ACAPI_Element_Delete with NoError(0) results but the Hotlink elements were not deleted in my project.
My end goal is to delete hotlink elements on specific floors. I don't want to delete all hotlink referenced to a single source/Hotlink Node.
I initially tried to use ACAPI_Element_Delete() to delete all hotlink elements based on their element guids. (err==0)
// Get all Hotlink elements
GS::Array<API_Guid> elemGuidList;
err = ACAPI_Element_GetElemList(API_HotlinkID, &elemGuidList);
if (err != NoError) return err;
// Delete all Hotlink elements
err = ACAPI_CallUndoableCommand("Element Test - Delete 2D HLM Element", [&]() -> GSErrCode {
return ACAPI_Element_Delete(elemGuidList);
});
if (err != NoError) return err;
But after i executed the process/code. the element still exist in my project
I already tried using ACAPI_Hotlink_DeleteHotlinkNode() but again, this method will delete all elements that uses/referenced to that hotlink node(I dont need to delete all hotlink elements based on the hotlink node)
Any Idea how can i delete specific hotlink element Example there are 2 hotlink element in ground floor and first floor(story) using the same hotlink source, I only want to delete the hotlink in first floor(Story) [Which is possible using Archicad software/done manually]
2024-05-05 06:09 PM - edited 2024-05-05 06:10 PM
[Update]
I realized that the hotlink module are somewhat group of elements that is why I tried getting the group elements and delete those elements.
However, It did work in one of my hotlink but not with my other hotlinks. Not sure why it was not returning any group elements(Empty GS::Array<API_Guid>) based on the hotlink group id when using ACAPI_Grouping_GetGroupedElems()
Still not sure what is the best approach to successfully delete a placed Hotlink.
Here is my current code:
// Get all hotlink elements
GS::Array<API_Guid> elemGuidList;
err = ACAPI_Element_GetElemList(API_HotlinkID, &elemGuidList);
DBPrintf("Number of found element type: %ld\n", elemGuidList.GetSize());
if (err != NoError) return err;
API_Element element;
GSErrCode elemErr;
std::vector<API_Element> elemList;
for (GS::Array<API_Guid>::ConstIterator it = elemGuidList.Enumerate(); it != nullptr; ++it)
{
BNZeroMemory(&element, sizeof(API_Element));
element.header.guid = *it;
elemErr = ACAPI_Element_Get(&element);
if (elemErr == NoError)
{
elemList.push_back(element);
DBPrintf("2D Hotlink Group Guid: %s\n", APIGuidToString(element.hotlink.hotlinkGroupGuid).ToCStr().Get());
GS::Array<API_Guid> deleteGuids = {};
err = ACAPI_Grouping_GetGroupedElems(element.hotlink.hotlinkGroupGuid, &deleteGuids);
if (err != NoError) return err;
err = ACAPI_CallUndoableCommand("Element Test - Delete 2D HLM Elements", [&]() -> GSErrCode {
return ACAPI_Element_Delete(deleteGuids);
});
if (err != NoError) return err;
}
}
Can be deleted: 2RF2-1.mod
Cannot be deleted: 3R-1.mod