sdaiGetAttr

valueType argument to specify what type of data caller wants to get and value argument where the caller should provide a buffer, and the function will write the result to. Table 1 shows type of buffer the caller should provide depending on the valueType for sdaiGetAttr, and it works similarly for all get-functions. Note: with SDAI API it is impossible to check buffer type at compilation or execution time and this is responsibility of a caller to ensure that requested valueType is matching with the value argument, a mismatch will lead to unpredictable results. The Table 2 shows what valueType can be fulfilled depending on actual model data. On success get-function will return non-zero. More precisely, according to ISO 10303-24-2001 on success they return content of value argument (*value) for sdaiADB, sdaiAGGR, or sdaiINSTANCE or value argument itself for other types (it has no useful meaning for C#). All get-functions return NULL and set value to 0 if model data are incompatible with requested valueType. Furthermore: - for unset ($) data all get-functions return NULL and set value to 0, except when valueType = sdaiEXPRESSSTRING - for derived (*), depending on engiEnableDerivedAttributes, and except valueType = sdaiEXPRESSSTRING: -- either calculate and follow these rues for calculated value -- or handles it as unset ($) - if valueType = sdaiEXPRESSSTRING and data is unset ($) or derived (*), get-function will return NULL but set value to "$" or "*" respectively for any engiEnableDerivedAttributes state

Table 1 – Required value buffer depending on valueType (on the example of sdaiGetAttr but valid for all get-functions)

valueType               C/C++                                                           C#

sdaiINTEGER             int_t val;                                                      int_t val;
                        sdaiGetAttr (instance, attribute, sdaiINTEGER, &val);           ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiINTEGER, out val);

sdaiREAL or sdaiNUMBER  double val;                                                     double val;
                        sdaiGetAttr (instance, attribute, sdaiREAL, &val);              ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiREAL, out val);

sdaiBOOLEAN             SdaiBoolean val;                                                bool val;
                        sdaiGetAttr (instance, attribute, sdaiBOOLEAN, &val);           ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiBOOLEAN, out val);

sdaiLOGICAL             const TCHAR* val;                                               string val;
                        sdaiGetAttr (instance, attribute, sdaiLOGICAL, &val);           ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiLOGICAL, out val);

sdaiENUM                const TCHAR* val;                                               string val;
                        sdaiGetAttr (instance, attribute, sdaiENUM, &val);              ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiENUM, out val);

sdaiBINARY              const TCHAR* val;                                               string val;
                        sdaiGetAttr (instance, attribute, sdaiBINARY, &val);            ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiBINARY, out val);

sdaiSTRING              const char* val;                                                string val;
                        sdaiGetAttr (instance, attribute, sdaiSTRING, &val);            ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiSTRING, out val);

sdaiUNICODE             const wchar_t* val;                                             string val;
                        sdaiGetAttr (instance, attribute, sdaiUNICODE, &val);           ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiUNICODE, out val);

sdaiEXPRESSSTRING       const char* val;                                                string val;
                        sdaiGetAttr (instance, attribute, sdaiEXPRESSSTRING, &val);     ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiEXPRESSSTRING, out val);

sdaiINSTANCE            SdaiInstance val;                                               int_t val;
                        sdaiGetAttr (instance, attribute, sdaiINSTANCE, &val);          ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiINSTANCE, out val);

sdaiAGGR                SdaiAggr aggr;                                                  int_t aggr;
                        sdaiGetAttr (instance, attribute, sdaiAGGR, &aggr);             ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiAGGR, out aggr);

sdaiADB                 SdaiADB adb = sdaiCreateEmptyADB();                             int_t adb = 0;  //  it is important to initialize
                        sdaiGetAttr (instance, attribute, sdaiADB, adb);                ifcengine.sdaiGetAttr (instance, attribute, ifcengine.sdaiADB, out adb);        
                        sdaiDeleteADB (adb);

                        SdaiADB adb = nullptr;  //  it is important to initialize
                        sdaiGetAttr (instance, attribute, sdaiADB, &adb);
TCHAR is “char” or “wchar_t” depending on setStringUnicode. (Non-standard behavior) sdaiLOGICAL behaves differently from ISO 10303-24-2001: it expects char* while standard declares int_t. (Non-standard extension) sdiADB in C++ has an option to work without sdaiCreateEmptyADB and sdaiDeleteADB as shown in the table.
Table 2 - valueType can be requested depending on actual model data.

valueType       Works for following values in the model
                  integer      real     .T. or .F.     .U.      other enum    binary      string     instance      list
sdaiINTEGER         Yes         Yes *        .           .           .           .           .           .           .
sdaiREAL            Yes         Yes          .           .           .           .           .           .           .
sdaiNUMBER          Yes         Yes          .           .           .           .           .           .           .
sdaiBOOLEAN          .           .          Yes          .           .           .           .           .           .
sdaiLOGICAL          .           .          Yes         Yes          .           .           .           .           .
sdaiENUM             .           .          Yes         Yes         Yes          .           .           .           .
sdaiBINARY           .           .           .           .           .          Yes          .           .           .
sdaiSTRING          Yes         Yes         Yes         Yes         Yes         Yes         Yes          .           .
sdaiUNICODE         Yes         Yes         Yes         Yes         Yes         Yes         Yes          .           .
sdaiEXPRESSSTRING   Yes         Yes         Yes         Yes         Yes         Yes         Yes          .           .
sdaiINSTANCE         .           .           .           .           .           .           .          Yes          .
sdaiAGGR             .           .           .           .           .           .           .           .          Yes
sdaiADB             Yes         Yes         Yes         Yes         Yes         Yes         Yes         Yes         Yes

(Non-standard extensions) sdaiGetADBValue: sdaiADB is allowed and will success when sdaiGetADBTypePath is not NULL, returning ABD value has type path element removed.

Syntax

public const string ifcenginedll = @"ifcengine.dll";

[DllImport(IFCEngineDLL, EntryPoint = "sdaiGetAttr")]
public static extern Int32 sdaiGetAttr(int_t instance, int_t attribute, int_t valueType, out bool value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiGetAttr")]
public static extern Int32 sdaiGetAttr(int_t instance, int_t attribute, int_t valueType, out int_t value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiGetAttr")]
public static extern Int32 sdaiGetAttr(int_t instance, int_t attribute, int_t valueType, out double value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiGetAttr")]
public static extern Int32 sdaiGetAttr(int_t instance, int_t attribute, int_t valueType, out IntPtr value);    

Property instance

Size: 32 bit / 4 byte (value)
...

Property attribute

Size: 32 bit / 4 byte (reference)
...

Property valueType

Size: 32 bit / 4 byte (value)
...

Property value

Size: 32 bit / 4 byte (reference)
...

Example (based on pure API calls)

Here you can find code snippits that show how the API call sdaiGetAttr can be used.

using RDF;      //  include at least engine.cs within your solution

Int64 localGetAttrBN(Int64 instance, byte[] attributeName, Int64 valueType, out Int64 value)
{
    //
    //  This function is an alternative to the API call sdaiGetAttrBN()
    //  based on sdaiGetAttr().
    //
    //  Use of sdaiGetAttr() can lead to performance improvement compared to sdaiGetAttrBN().
    //
    Int64 instanceType = ifcengine.sdaiGetInstanceType(instance),
          attribute = ifcengine.sdaiGetAttrDefinition(instanceType, attributeName);

    return ifcengine.sdaiGetAttr(instance, attribute, valueType, out value);
}

Int64 localGetAttrBN(Int64 instance, byte[] attributeName, Int64 valueType, out double value)
{
    //
    //  This function is an alternative to the API call sdaiGetAttrBN()
    //  based on sdaiGetAttr().
    //
    //  Use of sdaiGetAttr() can lead to performance improvement compared to sdaiGetAttrBN().
    //
    Int64 instanceType = ifcengine.sdaiGetInstanceType(instance),
          attribute = ifcengine.sdaiGetAttrDefinition(instanceType, attributeName);

    return ifcengine.sdaiGetAttr(instance, attribute, valueType, out value);
}

Int64 localGetAttrBN(Int64 instance, byte[] attributeName, Int64 valueType, out IntPtr value)
{
    //
    //  This function is an alternative to the API call sdaiGetAttrBN()
    //  based on sdaiGetAttr().
    //
    //  Use of sdaiGetAttr() can lead to performance improvement compared to sdaiGetAttrBN().
    //
    Int64 instanceType = ifcengine.sdaiGetInstanceType(instance),
          attribute = ifcengine.sdaiGetAttrDefinition(instanceType, attributeName);

    return ifcengine.sdaiGetAttr(instance, attribute, valueType, out value);
}