sdaiInsertAfter

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 sdaiInsertAfter, 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 sdaiInsertAfter but valid for all put-functions)

valueType               C/C++                                                       C#

sdaiINTEGER             int_t val = 123;                                            int_t val = 123;
                        sdaiInsertAfter (iterator, sdaiINTEGER, &val);              IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiINTEGER, ref val);

sdaiREAL or sdaiNUMBER  double val = 123.456;                                       double val = 123.456;
                        sdaiInsertAfter (iterator, sdaiREAL, &val);                 IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiREAL, ref val);

sdaiBOOLEAN             SdaiBoolean val = sdaiTRUE;                                 bool val = true;
                        sdaiInsertAfter (iterator, sdaiBOOLEAN, &val);              IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiBOOLEAN, ref val);

sdaiLOGICAL             const TCHAR* val = "U";                                     string val = "U";
                        sdaiInsertAfter (iterator, sdaiLOGICAL, val);               IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiLOGICAL, val);

sdaiENUM                const TCHAR* val = "NOTDEFINED";                            string val = "NOTDEFINED";
                        sdaiInsertAfter (iterator, sdaiENUM, val);                  IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiENUM, val);

sdaiBINARY              const TCHAR* val = "0123456ABC";                            string val = "0123456ABC";
                        sdaiInsertAfter (iterator, sdaiBINARY, val);                IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiBINARY, val);

sdaiSTRING              const char* val = "My Simple String";                       string val = "My Simple String";
                        sdaiInsertAfter (iterator, sdaiSTRING, val);                IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiSTRING, val);

sdaiUNICODE             const wchar_t* val = L"Any Unicode String";                 string val = "Any Unicode String";
                        sdaiInsertAfter (iterator, sdaiUNICODE, val);               IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiUNICODE, val);

sdaiEXPRESSSTRING       const char* val = "EXPRESS format, i.e. \\X2\\00FC\\X0\\";  string val = "EXPRESS format, i.e. \\X2\\00FC\\X0\\";
                        sdaiInsertAfter (iterator, sdaiEXPRESSSTRING, val);         IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiEXPRESSSTRING, val);

sdaiINSTANCE            SdaiInstance val = sdaiCreateInstanceBN (model, "IFCSITE"); int_t val = IFCEngine.sdaiCreateInstanceBN (model, "IFCSITE");
                        sdaiInsertAfter (iterator, sdaiINSTANCE, val);              IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiINSTANCE, val);

sdaiAGGR                SdaiAggr val = sdaiCreateAggr (inst, 0);                    int_t val = sdaiCreateAggr (inst, 0);
                        sdaiPutAttr (val, sdaiINSTANCE, inst);                      IFCEngine.sdaiPutAttr (val, IFCEngine.sdaiINSTANCE, inst);
                        sdaiInsertAfter (iterator, sdaiAGGR, val);                  IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiAGGR, val);

sdaiADB                 int_t integerValue = 123;                                   int_t integerValue = 123;   
                        SdaiADB val = sdaiCreateADB (sdaiINTEGER, &integerValue);   int_t val = IFCEngine.sdaiCreateADB (IFCEngine.sdaiINTEGER, ref integerValue);
                        sdaiPutADBTypePath (val, 1, "IFCINTEGER");                  IFCEngine.sdaiPutADBTypePath (val, 1, "IFCINTEGER");
                        sdaiInsertAfter (iterator, sdaiADB, val);                   IFCEngine.sdaiInsertAfter (iterator, IFCEngine.sdaiADB, val);   
                        ...                                                         ...
                        sdaiDeleteADB (val);    //  optional                        IFCEngine.sdaiDeleteADB (val);  //  optional
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 has an option to work without sdaiDeleteADB as shown in the table (all open ADB's will be deleted on model close).
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             Yes         Yes         Yes         Yes         Yes         Yes         Yes         Yes         Yes          .

Syntax

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

[DllImport(ifcenginedll, EntryPoint = "sdaiInsertAfter")]
public static extern void sdaiInsertAfter(int_t iterator, int_t valueType, [param: MarshalAs(UnmanagedType.U1)] ref bool value);

[DllImport(ifcenginedll, EntryPoint = "sdaiInsertAfter")]
public static extern void sdaiInsertAfter(int_t iterator, int_t valueType, ref int_t value);

[DllImport(ifcenginedll, EntryPoint = "sdaiInsertAfter")]
public static extern void sdaiInsertAfter(int_t iterator, int_t valueType, int_t value);

[DllImport(ifcenginedll, EntryPoint = "sdaiInsertAfter")]
public static extern void sdaiInsertAfter(int_t iterator, int_t valueType, ref double value);

[DllImport(ifcenginedll, EntryPoint = "sdaiInsertAfter")]
public static extern void sdaiInsertAfter(int_t iterator, int_t valueType, ref IntPtr value);

[DllImport(ifcenginedll, EntryPoint = "sdaiInsertAfter")]
public static extern void sdaiInsertAfter(int_t iterator, int_t valueType, byte[] value);

public static void sdaiInsertAfter(int_t iterator, int_t valueType, string value)
        {
            valueType = getStringType(valueType);
            if (valueType != 0)
            {
                var bytes = stringToBytes(valueType, value);
                if (bytes != null)
                {
                    sdaiInsertAfter(iterator, valueType, bytes);
                }
            }
        }    

Property iterator

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

Property valueType

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

Property value

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