The following are simple data types of attributes:
sdaiINTEGER
sdaiREAL
sdaiNUMBER
sdaiBOOLEAN
sdaiLOGICAL
sdaiSTRING
sdaiINSTANCE
Any application instance can contain attributes of any data type listed above.
To get access to an attribute, use the sdaiGetAttrBN()
function in the following routine:
_sdaiGetEntityById()
function call:
SdaiAppInstance applicationInstance = _sdaiGetEntityById(model, 5);
if ((applicationInstance == NULL) || (sdaiErrorQuery() != sdaiNO_ERR))
return;
sdaiGetAttrBN()
function:
SdaiAppInstance developer = NULL;
if (sdaiGetAttrBN(applicationInstance, "applicationdeveloper", sdaiINSTANCE, &developer ) == NULL)
return;
if ((developer == NULL) || (sdaiErrorQuery() != sdaiNO_ERR))
return;
The sdaiGetAttrBN()
function
accepts four parameters:
NULL
otherwise.
The code fragment illustrates how to get an attribute represented with an instance.
Below you can find another example of getting access to a simple attribute value: a string value of the version.
In the first case, it is retrieved as a string and the
sdaiGetAttrBN()
function
returns it successfully; in the second case, you can see an attempt to get a string attribute as an integer value.
This attempt fails; the sdaiGetAttrBN()
function
returns NULL, and the sdaiErrorQuery()
function returns an sdaiVT_NVLD
value.
SdaiString version = NULL;
if ((sdaiGetAttrBN(applicationInstance, "version", sdaiSTRING, &version ) == NULL) || (odStrCmpA(version, "2019") != 0) || (sdaiErrorQuery() != sdaiNO_ERR))
return;
SdaiInteger wrongAttrType = -1;
if (sdaiGetAttrBN(applicationInstance, "version", sdaiINTEGER, &wrongAttrType ) == NULL)
return;
Another kind of simple type is an enumeration. SDAI also supports getting enumeration values from an application instance.
For example, an .ifc file contains an entry in the DATA
section:
// #43= IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
The string value within the dots is an enumeration value. Below you can see a code fragment that read this value.
// #43= IFCSIUNIT(*,.LENGTHUNIT.,.MILLI.,.METRE.);
SdaiAppInstance applicationInstance = _sdaiGetEntityById(model, 43);
if ((applicationInstance == NULL) || (sdaiErrorQuery() != sdaiNO_ERR))
return;
SdaiEnum enumValue = NULL;
// if successful, the enumValue contains "MILLI"
if (sdaiGetAttrBN(applicationInstance, "prefix", sdaiENUM, &enumValue ) == NULL)
return;
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.
|