Select attributes can contain values of different types. To provide storage of different types of values with different lengths in bytes, the attribute data block (ADB) is used.
This topic shows how these attributes can be read.
It is assumed that there is an instance similar to the following in an .ifc file (with an attribute select value):
// #49 = IFCMEASUREWITHUNIT(IFCRATIOMEASURE(0.0174532925199433), #47);
It has a select attribute named "valuecomponent". To get access to its value and work with it, follow the routine below:
_sdaiGetEntityById()
function call:
SdaiAppInstance applicationInstance = _sdaiGetEntityById(model, 49);
if ((applicationInstance == NULL) || (sdaiErrorQuery() != sdaiNO_ERR))
return;
sdaiGetAttrBN()
function.
But for getting access to a select attribute, pass an already created ADB value as the fourth parameter to this function.
To create a new ADB value, call the sdaiCreateEmptyADB()
function:
SdaiADB adbToGet = sdaiCreateEmptyADB();
if (adbToGet != NULL)
{
if (sdaiGetAttrBN(applicationInstance, "valuecomponent", sdaiADB, &adbToGet ) == NULL)
return;
}
IFCRATIOMEASURE(0.0174532925199433)
),
therefore you have to get the attribute value as a real data type value:
SdaiReal adbRealValue = .0;
sdaiGetADBValue(adbToGet, sdaiREAL, &adbRealValue );
if (!OdEqual(0.0174532925199433, adbRealValue))
return;
According to the code fragment, the sdaiGetADBValue()
function should be called to get a value from an attribute data block.
This function accepts three parameters:
The sdaiGetADBValue()
function returns a raw pointer to
the attribute value if it is successfully retrieved or the NULL
value in the other case so you can check the result of the ADB operation.
Another type of data that can be stored in an attribute data block is a path. The path contains an array of strings and can be obtained by
the call of the sdaiGetADBTypePath
function:
SdaiInteger collectionSize = 0;
SdaiString* pathCollection = sdaiGetADBTypePath(adbToGet, &collectionSize);
if (collectionSize > 0)
{
for (SdaiInteger pathIndex = 0; pathIndex < collectionSize; ++pathIndex)
{
if (!pathCollection[pathIndex] || odStrLenA(pathCollection[pathIndex]) <= 0)
return;
}
}
The sdaiGetADBTypePath()
function returns a raw pointer
to a string array if successful or the NULL
value in the other case.
sdaiDeleteADB()
function to delete it and free the memory:
sdaiDeleteADB(adbToGet);
if (sdaiErrorQuery() != sdaiNO_ERR)
return;
Work with Aggregate Attributes
Copyright © 2002 – 2021. Open Design Alliance. All rights reserved.
|