sdaiAdd

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

valueType               C/C++                                                       C#

sdaiINTEGER             int_t val = 123;                                            int_t val = 123;
                        sdaiAdd (aggregate, sdaiINTEGER, &val);                     stepengine.sdaiAdd (aggregate, stepengine.sdaiINTEGER, ref val);

sdaiREAL or sdaiNUMBER  double val = 123.456;                                       double val = 123.456;
                        sdaiAdd (aggregate, sdaiREAL, &val);                        stepengine.sdaiAdd (aggregate, stepengine.sdaiREAL, ref val);

sdaiBOOLEAN             SdaiBoolean val = sdaiTRUE;                                 bool val = true;
                        sdaiAdd (aggregate, sdaiBOOLEAN, &val);                     stepengine.sdaiAdd (aggregate, stepengine.sdaiBOOLEAN, ref val);

sdaiLOGICAL             const TCHAR* val = "U";                                     string val = "U";
                        sdaiAdd (aggregate, sdaiLOGICAL, val);                      stepengine.sdaiAdd (aggregate, stepengine.sdaiLOGICAL, val);

sdaiENUM                const TCHAR* val = "NOTDEFINED";                            string val = "NOTDEFINED";
                        sdaiAdd (aggregate, sdaiENUM, val);                         stepengine.sdaiAdd (aggregate, stepengine.sdaiENUM, val);

sdaiBINARY              const TCHAR* val = "0123456ABC";                            string val = "0123456ABC";
                        sdaiAdd (aggregate, sdaiBINARY, val);                       stepengine.sdaiAdd (aggregate, stepengine.sdaiBINARY, val);

sdaiSTRING              const char* val = "My Simple String";                       string val = "My Simple String";
                        sdaiAdd (aggregate, sdaiSTRING, val);                       stepengine.sdaiAdd (aggregate, stepengine.sdaiSTRING, val);

sdaiUNICODE             const wchar_t* val = L"Any Unicode String";                 string val = "Any Unicode String";
                        sdaiAdd (aggregate, sdaiUNICODE, val);                      stepengine.sdaiAdd (aggregate, stepengine.sdaiUNICODE, val);

sdaiEXPRESSSTRING       const char* val = "EXPRESS format, i.e. \\X2\\00FC\\X0\\";  string val = "EXPRESS format, i.e. \\X2\\00FC\\X0\\";
                        sdaiAdd (aggregate, sdaiEXPRESSSTRING, val);                stepengine.sdaiAdd (aggregate, stepengine.sdaiEXPRESSSTRING, val);

sdaiINSTANCE            SdaiInstance val = sdaiCreateInstanceBN (model, "PRODUCT"); int_t val = stepengine.sdaiCreateInstanceBN (model, "PRODUCT");
                        sdaiAdd (aggregate, sdaiINSTANCE, val);                     stepengine.sdaiAdd (aggregate, stepengine.sdaiINSTANCE, val);

sdaiAGGR                SdaiAggr val = sdaiCreateAggr (inst, 0);                    int_t val = sdaiCreateAggr (inst, 0);
                        sdaiPutAttr (val, sdaiINSTANCE, inst);                      stepengine.sdaiPutAttr (val, stepengine.sdaiINSTANCE, inst);
                        sdaiAdd (aggregate, sdaiAGGR, val);                         stepengine.sdaiAdd (aggregate, stepengine.sdaiAGGR, val);

sdaiADB                 int_t integerValue = 123;                                   int_t integerValue = 123;   
                        SdaiADB val = sdaiCreateADB (sdaiINTEGER, &integerValue);   int_t val = ifcengine.sdaiCreateADB (stepengine.sdaiINTEGER, ref integerValue);
                        sdaiPutADBTypePath (val, 1, "INTEGER");                     stepengine.sdaiPutADBTypePath (val, 1, "INTEGER");
                        sdaiAdd (aggregate, sdaiADB, val);                          stepengine.sdaiAdd (aggregate, stepengine.sdaiADB, val);    
                        sdaiDeleteADB (val);                                        stepengine.sdaiDeleteADB (val);
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             Yes         Yes         Yes         Yes         Yes         Yes         Yes         Yes         Yes          .

Syntax

public const string enginedll = @"engine.dll";

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x86_sdaiAdd(Int32 aggregate, Int32 valueType, ref bool value);

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x64_sdaiAdd(Int64 aggregate, Int64 valueType, ref bool value);

public static void sdaiAdd(Int64 aggregate, Int64 valueType, ref bool value)
		{
			if (IntPtr.Size == 4)
			{
				bool _value = (bool)value;
				x86_sdaiAdd((Int32)aggregate, (Int32)valueType, ref _value);
				value = _value;
			}
			else
			{
				x64_sdaiAdd(aggregate, valueType, ref value);
			}
		}

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x86_sdaiAdd(Int32 aggregate, Int32 valueType, ref Int32 value);

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x64_sdaiAdd(Int64 aggregate, Int64 valueType, ref Int64 value);

public static void sdaiAdd(Int64 aggregate, Int64 valueType, ref Int64 value)
		{
			if (IntPtr.Size == 4)
			{
				Int32 _value = (Int32)value;
				x86_sdaiAdd((Int32)aggregate, (Int32)valueType, ref _value);
				value = _value;
			}
			else
			{
				x64_sdaiAdd(aggregate, valueType, ref value);
			}
		}

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x86_sdaiAdd(Int32 aggregate, Int32 valueType, Int32 value);

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x64_sdaiAdd(Int64 aggregate, Int64 valueType, Int64 value);

public static void sdaiAdd(Int64 aggregate, Int64 valueType, Int64 value)
		{
			if (IntPtr.Size == 4)
			{
				x86_sdaiAdd((Int32)aggregate, (Int32)valueType, (Int32)value);
			}
			else
			{
				x64_sdaiAdd(aggregate, valueType, value);
			}
		}

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x86_sdaiAdd(Int32 aggregate, Int32 valueType, ref double value);

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x64_sdaiAdd(Int64 aggregate, Int64 valueType, ref double value);

public static void sdaiAdd(Int64 aggregate, Int64 valueType, ref double value)
		{
			if (IntPtr.Size == 4)
			{
				double _value = (double)value;
				x86_sdaiAdd((Int32)aggregate, (Int32)valueType, ref _value);
				value = _value;
			}
			else
			{
				x64_sdaiAdd(aggregate, valueType, ref value);
			}
		}

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x86_sdaiAdd(Int32 aggregate, Int32 valueType, ref IntPtr value);

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x64_sdaiAdd(Int64 aggregate, Int64 valueType, ref IntPtr value);

public static void sdaiAdd(Int64 aggregate, Int64 valueType, ref IntPtr value)
		{
			if (IntPtr.Size == 4)
			{
				IntPtr _value = (IntPtr)value;
				x86_sdaiAdd((Int32)aggregate, (Int32)valueType, ref _value);
				value = _value;
			}
			else
			{
				x64_sdaiAdd(aggregate, valueType, ref value);
			}
		}

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x86_sdaiAdd(Int32 aggregate, Int32 valueType, byte[] value);

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x64_sdaiAdd(Int64 aggregate, Int64 valueType, byte[] value);

public static void sdaiAdd(Int64 aggregate, Int64 valueType, byte[] value)
		{
			if (IntPtr.Size == 4)
			{
				x86_sdaiAdd((Int32)aggregate, (Int32)valueType, value);
			}
			else
			{
				x64_sdaiAdd(aggregate, valueType, value);
			}
		}

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x86_sdaiAdd(Int32 aggregate, Int32 valueType, string value);

[DllImport(enginedll, EntryPoint = "sdaiAdd")]
public static extern void x64_sdaiAdd(Int64 aggregate, Int64 valueType, string value);

public static void sdaiAdd(Int64 aggregate, Int64 valueType, string value)
		{
			if (IntPtr.Size == 4)
			{
				x86_sdaiAdd((Int32)aggregate, (Int32)valueType, value);
			}
			else
			{
				x64_sdaiAdd(aggregate, valueType, value);
			}
		}    

Property aggregate

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

Property valueType

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

Property value

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