Provides functions to create and handle element sets for any kind of purpose. You may also add custom information to the element set.
More...
Provides functions to create and handle element sets for any kind of purpose. You may also add custom information to the element set.
Element Set Manager
The Element Set Manager lets your add-on mark a group of elements to be treated as a collection.
For example you have a building schedule database, and you want to assign elements to the tasks they are involved in. So you can create an element set for this task. Since an element can belong to more than one task, different element sets can contain the same element as well.
The elements in the set are referenced by their GUIDs. The Element Set Manager service automatically updates the GUID lists at merge or paste operations, when ID collision could happen.
You may also attach custom user data to an element set.
Note that from Archicad 12 element sets are referenced with their GUIDs rather than indices, because element sets can be re-indexed during the lifetime of a project, and that could have made difficult to follow up.
Functions
The Element Set Manager functions begin with the ACAPI_ElementSet_ prefix.
If you would like to store data into the project file that independent from the element database (that is it does not contain element unique ID references), you can use the ModulData Manager service.
◆ ACAPI_ElementSet_Create()
Groups elements into an element set.
- Parameters
-
guids | [in] Handle to the array of element GUIDs. |
userData | [in] User data assigned to the set (optional, can be nullptr). |
setGuid | [out] The unique ID of the newly created element set. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADPARS - guids or setGuid parameter is nullptr.
- APIERR_BADDATABASE, APIERR_NOTMINE - The function cannot operate on the current database.
- APIERR_NEEDSUNDOSCOPE - The function must be undoable, it wasn't called from an undoable command scope.
- APIERR_BADPLATFORMSIGN - The given platform sign is invalid.
- APIERR_MEMFULL - There is not enough memory to complete the operation.
- Example
GS::Array<API_Guid> guids;
for (USize i = API_WallID; i < static_cast<USize> (API_WallID) + 4; i++)
{
GS::Array<API_Guid> elemList;
if (!elemList.IsEmpty ())
guids.Push (elemList[0]);
else
guids.Push (APNULLGuid);
}
}
BNZeroMemory (&userData, sizeof (userData));
userData.
dataHdl = BMAllocateHandle (1024, ALLOCATE_CLEAR, 0);
sprintf (*userData.
dataHdl,
"Original element count: 4, guids [%s,%s,%s,%s]",
}
[&] () -> GSErrCode {
if (err != NoError) {
DBPRINTF ("Create Element Set error: %d/n", err);
}
return err;
});
GSErrCode ACAPI_CallUndoableCommand(const GS::UniString &undoString, const std::function< GSErrCode()> &command)
Performs an undoable operation.
GS::Guid & APIGuid2GSGuid(API_Guid &guid)
Converting from API_Guid to a GS::Guid.
Definition: API_Guid.hpp:73
GSErrCode ACAPI_Element_GetElemList(const API_ElemType &type, GS::Array< API_Guid > *elemList, API_ElemFilterFlags filterBits=APIFilt_None, const API_Guid &renovationFilterGuid=APINULLGuid)
Returns an array of guids of the elements of the given type.
API_ElemTypeID
The type of an element.API_ElemType variationID APIVarId_Generic.
Definition: APIdefs_Elements.h:74
GSErrCode ACAPI_ElementSet_Create(GS::Array< API_Guid > *guids, const API_UserData *userData, API_Guid *setGuid)
Groups elements into an element set.
Represents a GS::Guid in the API layer.
Definition: API_Guid.hpp:46
Custom data record attached to element sets.
Definition: APIdefs_Elements.h:18359
GSHandle dataHdl
handle containing the user data (arbitrary size)
Definition: APIdefs_Elements.h:18392
short dataVersion
the version of the user data
Definition: APIdefs_Elements.h:18365
unsigned short platformSign
the platform the data was created on; defines the byte ordering (can be GS::Win_Platform_Sign,...
Definition: APIdefs_Elements.h:18371
◆ ACAPI_ElementSet_Delete()
GSErrCode ACAPI_ElementSet_Delete |
( |
API_Guid |
setGuid | ) |
|
Deletes an existing element set.
- Parameters
-
setGuid | [in] The GUID of the element set to be deleted. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADDATABASE - The function cannot operate on the current database.
- APIERR_NEEDSUNDOSCOPE - The function must be undoable, it wasn't called from an undoable command scope.
- APIERR_BADID - The setGuid parameter is invalid.
- APIERR_NOTMINE - The element set referenced by setGuid is owned by another user.
- APIERR_DELETED - The element set is already deleted.
- Example
void DeleteElementSets (
const API_Guid& guid)
{
GS::Array<API_Guid> setGuids;
if (err == NoError) {
USize nSet = setGuids.GetSize ();
[&] () -> GSErrCode {
for (UIndex i = 0; i < nSet; i++) {
if (err != NoError) {
DBPRINTF ("Delete Element Set error: %d\n", err);
}
}
return NoError;
});
}
}
GSErrCode ACAPI_ElementSet_Delete(API_Guid setGuid)
Deletes an existing element set.
GSErrCode ACAPI_ElementSet_Identify(API_Guid elemGuid, GS::Array< API_Guid > *setGuids)
Retrieves the element sets that contain a given element.
◆ ACAPI_ElementSet_GetData()
Retrieves the data of an existing element set.
- Parameters
-
setGuid | [in] The GUID that identifies the element set. |
elemGuids | [out] Pointer to the array of element GUIDs. |
data | [out] User data assigned to the set. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADDATABASE - The function cannot operate on the current database.
- APIERR_BADID - The setGuid parameter is invalid.
- APIERR_NOTMINE - The element set referenced by setGuid is owned by another user.
- APIERR_DELETED - The element set is already deleted.
◆ ACAPI_ElementSet_Identify()
GSErrCode ACAPI_ElementSet_Identify |
( |
API_Guid |
elemGuid, |
|
|
GS::Array< API_Guid > * |
setGuids |
|
) |
| |
Retrieves the element sets that contain a given element.
- Parameters
-
elemGuid | [in] The element GUID to search for, or GS::NULLGuid to get all element sets. |
setGuids | [out] Array of GUIDs of the element sets that contain the element. |
- Returns
- NoError - The function has completed with success.
- APIERR_BADPARS - The setGuids parameter is nullptr.
- APIERR_BADDATABASE - The function cannot operate on the current database.