sdaiCreateADB

valueType argument to specify what type of data caller wants to put Table 1 shows type of buffer the caller should provide depending on the valueType for sdaiCreateADB, and it works similarly for all put-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.

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

valueType               C/C++                                                       C#

sdaiINTEGER             int_t val = 123;                                            int_t val = 123;
                        SdaiADB adb = sdaiCreateADB (sdaiINTEGER, &val);            int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiINTEGER, ref val);

sdaiREAL or sdaiNUMBER  double val = 123.456;                                       double val = 123.456;
                        SdaiADB adb = sdaiCreateADB (sdaiREAL, &val);               int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiREAL, ref val);

sdaiBOOLEAN             bool val = true;                                            bool val = true;
                        SdaiADB adb = sdaiCreateADB (sdaiBOOLEAN, &val);            int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiBOOLEAN, ref val);

sdaiLOGICAL             const TCHAR* val = "U";                                     string val = "U";
                        SdaiADB adb = sdaiCreateADB (sdaiLOGICAL, val);             int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiLOGICAL, val);

sdaiENUM                const TCHAR* val = "NOTDEFINED";                            string val = "NOTDEFINED";
                        SdaiADB adb = sdaiCreateADB (sdaiENUM, val);                int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiENUM, val);

sdaiBINARY              const TCHAR* val = "0123456ABC";                            string val = "0123456ABC";
                        SdaiADB adb = sdaiCreateADB (sdaiBINARY, val);              int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiBINARY, val);

sdaiSTRING              const char* val = "My Simple String";                       string val = "My Simple String";
                        SdaiADB adb = sdaiCreateADB (sdaiSTRING, val);              int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiSTRING, val);

sdaiUNICODE             const wchar_t* val = L"Any Unicode String";                 string val = "Any Unicode String";
                        SdaiADB adb = sdaiCreateADB (sdaiUNICODE, val);             int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiSTRING, val);

sdaiEXPRESSSTRING       const char* val = "EXPRESS format, i.e. \\X2\\00FC\\X0\\";  string val = "EXPRESS format, i.e. \\X2\\00FC\\X0\\";
                        SdaiADB adb = sdaiCreateADB (sdaiEXPRESSSTRING, val);       int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiEXPRESSSTRING, val);

sdaiINSTANCE            SdaiInstance val = sdaiCreateInstanceBN (model, "IFCSITE"); int_t val = ifcengine.sdaiCreateInstanceBN (model, "IFCSITE");
                        SdaiADB adb = sdaiCreateADB (sdaiINSTANCE, val);            int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiINSTANCE, val);

sdaiAGGR                SdaiAggr val = sdaiCreateAggr (inst, 0);                    int_t val = sdaiCreateAggr (inst, 0);
                        sdaiAppend (val, sdaiINSTANCE, inst);                       ifcengine.sdaiAppend (val, ifcengine.sdaiINSTANCE, inst);
                        SdaiADB adb = sdaiCreateADB (sdaiAGGR, val);                int_t adb = ifcengine.sdaiCreateADB (ifcengine.sdaiAGGR, val);

sdaiADB                 not applicable
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      $ (empty)
sdaiINTEGER         Yes          .           .           .           .           .           .           .           .           .
sdaiREAL             .          Yes          .           .           .           .           .           .           .           .
sdaiNUMBER           .          Yes          .           .           .           .           .           .           .           .
sdaiBOOLEAN          .           .          Yes          .           .           .           .           .           .           .
sdaiLOGICAL          .           .          Yes         Yes          .           .           .           .           .           .
sdaiENUM             .           .          Yes         Yes         Yes          .           .           .           .           .
sdaiBINARY           .           .           .           .           .          Yes          .           .           .           .
sdaiSTRING           .           .           .           .           .           .          Yes          .           .           .
sdaiUNICODE          .           .           .           .           .           .          Yes          .           .           .
sdaiEXPRESSSTRING    .           .           .           .           .           .          Yes          .           .           .
sdaiINSTANCE         .           .           .           .           .           .           .          Yes          .           .
sdaiAGGR             .           .           .           .           .           .           .           .          Yes          .
sdaiADB              .           .           .           .           .           .           .           .           .           .

Syntax

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

[DllImport(IFCEngineDLL, EntryPoint = "sdaiCreateADB")]
public static extern Int64 sdaiCreateADB(int_t valueType, ref bool value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiCreateADB")]
public static extern Int64 sdaiCreateADB(int_t valueType, ref int_t value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiCreateADB")]
public static extern Int64 sdaiCreateADB(int_t valueType, int_t value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiCreateADB")]
public static extern Int64 sdaiCreateADB(int_t valueType, ref double value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiCreateADB")]
public static extern Int64 sdaiCreateADB(int_t valueType, ref IntPtr value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiCreateADB")]
public static extern Int64 sdaiCreateADB(int_t valueType, byte[] value);

[DllImport(IFCEngineDLL, EntryPoint = "sdaiCreateADB")]
public static extern Int64 sdaiCreateADB(int_t valueType, string value);    

Property valueType

Size: 64 bit / 8 byte (value)
...

Property value

Size: 64 bit / 8 byte (reference)
...

Example (based on pure API calls)

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

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

//
//  #13131 = IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(1.745E-2), #31313);
//  #31313 = IFCSIUNIT(*, .PLANEANGLEUNIT., $, .RADIAN.);
//

Int64 buildSIUnitInstance(Int64 model, string UnitType, string Prefix, string Name)
{
    //  #31313 = IFCSIUNIT(*, .PLANEANGLEUNIT., $, .RADIAN.);
    Int64 ifcSIUnitInstance = IfcEngine.x64.sdaiCreateInstanceBN(model, System.Text.Encoding.UTF8.GetBytes("IFCSIUNIT"));

    IfcEngine.x64.sdaiPutAttrBN(ifcSIUnitInstance, System.Text.Encoding.UTF8.GetBytes("UnitType"), IfcEngine.x64.sdaiENUM, System.Text.Encoding.UTF8.GetBytes(UnitType));
    if (Prefix != null)
    {
        IfcEngine.x64.sdaiPutAttrBN(ifcSIUnitInstance, System.Text.Encoding.UTF8.GetBytes("Prefix"), IfcEngine.x64.sdaiENUM, System.Text.Encoding.UTF8.GetBytes(Prefix));
    }
    IfcEngine.x64.sdaiPutAttrBN(ifcSIUnitInstance, System.Text.Encoding.UTF8.GetBytes("Name"), IfcEngine.x64.sdaiENUM, System.Text.Encoding.UTF8.GetBytes(Name));

    return ifcSIUnitInstance;
}

Int64 buildMeasureWithUnitInstance(Int64 model)
{
    Int64 valueComponentADB;
    double valueComponent = 0.01745;

    //  #13131 = IFCMEASUREWITHUNIT(IFCPLANEANGLEMEASURE(1.745E-2), #31313);
    Int64 ifcMeasureWithUnitInstance = IfcEngine.x64.sdaiCreateInstanceBN(model, System.Text.Encoding.UTF8.GetBytes("IFCMEASUREWITHUNIT"));

    valueComponentADB = IfcEngine.x64.sdaiCreateADB(IfcEngine.x64.sdaiREAL, ref valueComponent);
    IfcEngine.x64.sdaiPutADBTypePath(valueComponentADB, 1, System.Text.Encoding.UTF8.GetBytes("IFCPLANEANGLEMEASURE"));
    IfcEngine.x64.sdaiPutAttrBN(ifcMeasureWithUnitInstance, System.Text.Encoding.UTF8.GetBytes("ValueComponent"), IfcEngine.x64.sdaiADB, ref valueComponentADB);

    IfcEngine.x64.sdaiPutAttrBN(ifcMeasureWithUnitInstance, System.Text.Encoding.UTF8.GetBytes("UnitComponent"), IfcEngine.x64.sdaiINSTANCE, ref buildSIUnitInstance(model, "PLANEANGLEUNIT", null, "RADIAN"));

    return ifcMeasureWithUnitInstance;
}