2023-10-15 04:21 PM - last edited on 2024-09-16 02:27 PM by Doreena Deng
Hi guys,
I want to get all API_ObjectID of a API_LibPart in active floor. Do you know any way? Can you tell me?
Thank you very much.
2023-10-15 11:58 PM
Hi!
Here's some sample code. I haven't tested it but it should be very close to what you need:
GSErrCode IterateThroughListLibPartsOnCurrentFloor ()
{
API_LibPart libPart{};
CHCopyC ("{GUID OF YOUR LIBPART HERE}-{00000000-0000-0000-0000-000000000000}",
libPart.ownUnID);
GSErrCode err = ACAPI_LibPart_Search (&libPart, false);
if (err != NoError) { return err; }
if (libPart.location != nullptr) {
delete libPart.location;
libPart.location = nullptr;
}
GS::Array<API_Guid> objectList;
err = ACAPI_Element_GetElemList (API_ObjectID, &objectList, APIFilt_OnActFloor);
if (err != NoError) { return err; }
for (const auto objectGuid : objectList) {
API_Element objectElem{};
objectElem.header.guid = objectGuid;
err = ACAPI_Element_Get (&objectElem);
if (err != NoError) { return err; }
if (libPart.index == objectElem.object.libInd) {
// Here you have a placed object element from the library part
}
}
return err;
}