SetDatatypeProperty
The value of card gives the actual card of the values list.
The list values of undefined (void) items is a list of booleans, chars, integers
or doubles, this list has a length as givin in the values card. The actual used type
is given by the definition of the dataTypeProperty.
The return value always should be 0, if not something is wrong in the way this property is called.
Note: the client application needs to make sure the cardinality of
the property is within the boundaries.
Syntax
public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "SetDatatypeProperty")] public static extern Int64 SetDatatypeProperty(Int64 owlInstance, Int64 rdfProperty, ref byte values, Int64 card); [DllImport(EngineDLL, EntryPoint = "SetDatatypeProperty")] public static extern Int64 SetDatatypeProperty(Int64 owlInstance, Int64 rdfProperty, byte[] values, Int64 card); [DllImport(EngineDLL, EntryPoint = "SetDatatypeProperty")] public static extern Int64 SetDatatypeProperty(Int64 owlInstance, Int64 rdfProperty, ref Int64 values, Int64 card); [DllImport(EngineDLL, EntryPoint = "SetDatatypeProperty")] public static extern Int64 SetDatatypeProperty(Int64 owlInstance, Int64 rdfProperty, Int64[] values, Int64 card); [DllImport(EngineDLL, EntryPoint = "SetDatatypeProperty")] public static extern Int64 SetDatatypeProperty(Int64 owlInstance, Int64 rdfProperty, ref double values, Int64 card); [DllImport(EngineDLL, EntryPoint = "SetDatatypeProperty")] public static extern Int64 SetDatatypeProperty(Int64 owlInstance, Int64 rdfProperty, double[] values, Int64 card); [DllImport(EngineDLL, EntryPoint = "SetDatatypeProperty")] public static extern Int64 SetDatatypeProperty(Int64 owlInstance, Int64 rdfProperty, ref string values, Int64 card); [DllImport(EngineDLL, EntryPoint = "SetDatatypeProperty")] public static extern Int64 SetDatatypeProperty(Int64 owlInstance, Int64 rdfProperty, string[] values, Int64 card);
Property owlInstance
Size: 64 bit / 8 byte (value)Property rdfProperty
Size: 64 bit / 8 byte (value)Property values
Size: 64 bit / 8 byte (reference)Property card
Size: 64 bit / 8 byte (value)
Example
Here you can find code snippits that show how the API call SetDatatypeProperty can be used.
using Engine; static void Main(string[] args) { Int64 model = Engine.x86_64.CreateModel(); if (model != 0) { // // Classes // Int64 classAbcd = Engine.x86_64.CreateClass(model, "ABCD"); // // Datatype Properties (attributes) // Int64 propertyAb = Engine.x86_64.CreateProperty(model, Engine.x86_64.DATATYPEPROPERTY_TYPE_BOOLEAN, "Ab"), propertyCd = Engine.x86_64.CreateProperty(model, Engine.x86_64.DATATYPEPROPERTY_TYPE_CHAR, "Cd"), propertyEf = Engine.x86_64.CreateProperty(model, Engine.x86_64.DATATYPEPROPERTY_TYPE_INTEGER, "Ef"), propertyGh = Engine.x86_64.CreateProperty(model, Engine.x86_64.DATATYPEPROPERTY_TYPE_DOUBLE, "Gh"); // // Instances // Int64 instanceAbcd = Engine.x86_64.CreateInstance(classAbcd, (string) null); // // Set Properties // { bool[] valuesAb = { true, false }; byte[] valuesAb_inByte = valuesAb.Select((v) => { return v ? (byte) 1 : (byte) 0; }).ToArray(); Engine.x86_64.SetDatatypeProperty(instanceAbcd, propertyAb, valuesAb_inByte, 2); string[] valuesCd = { "First Line", "Second Line" }; Engine.x86_64.SetDatatypeProperty(instanceAbcd, propertyCd, valuesCd, 2); Int64[] valuesEf = { 1234, 5678 }; Engine.x86_64.SetDatatypeProperty(instanceAbcd, propertyEf, valuesEf, 2); double[] valuesGh = { 12.34, 56.78 }; Engine.x86_64.SetDatatypeProperty(instanceAbcd, propertyGh, valuesGh, 2); } // // Get Properties // { Int64 card = 0; IntPtr valuesPtr = IntPtr.Zero; Engine.x86_64.GetDatatypeProperty(instanceAbcd, propertyAb, out valuesPtr, out card); System.Diagnostics.Debug.Assert(card == 2); if (card > 0) { byte[] values_inByte = new byte[card]; System.Runtime.InteropServices.Marshal.Copy(valuesPtr, values_inByte, 0, (int)card); bool[] values = values_inByte.Select((v) => { return v != 0; }).ToArray(); System.Diagnostics.Debug.Assert(values[0] == true && values[1] == false); } } { Int64 card = 0; IntPtr valuesPtr = IntPtr.Zero; Engine.x86_64.GetDatatypeProperty(instanceAbcd, propertyCd, out valuesPtr, out card); System.Diagnostics.Debug.Assert(card == 2); if (card > 0) { IntPtr[] valuesRef = new IntPtr[card]; System.Runtime.InteropServices.Marshal.Copy(valuesPtr, valuesRef, 0, (int) card); string[] values = new string[card]; for (int i = 0; i < (int) card; i++) { values[i] = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(valuesRef[i]); } System.Diagnostics.Debug.Assert(values[0].Equals("First Line") && values[1].Equals("Second Line")); } } { Int64 card = 0; IntPtr valuesPtr = IntPtr.Zero; Engine.x86_64.GetDatatypeProperty(instanceAbcd, propertyEf, out valuesPtr, out card); System.Diagnostics.Debug.Assert(card == 2); if (card > 0) { Int64[] values = new Int64[card]; System.Runtime.InteropServices.Marshal.Copy(valuesPtr, values, 0, (int) card); System.Diagnostics.Debug.Assert(values[0] == 1234 && values[1] == 5678); } } { Int64 card = 0; IntPtr valuesPtr = IntPtr.Zero; Engine.x86_64.GetDatatypeProperty(instanceAbcd, propertyGh, out valuesPtr, out card); System.Diagnostics.Debug.Assert(card == 2); if (card > 0) { double[] values = new double[card]; System.Runtime.InteropServices.Marshal.Copy(valuesPtr, values, 0, (int) card); System.Diagnostics.Debug.Assert(values[0] == 12.34 && values[1] == 56.78); } } // // The same can be applied to existing classes and properties // // // Classes // Int64 classCylinder = Engine.x86_64.GetClassByName(model, "Cylinder"); // // Datatype Properties (attributes) // Int64 propertyClosed = Engine.x86_64.GetPropertyByName(model, "closed"), propertyLength = Engine.x86_64.GetPropertyByName(model, "length"), propertyName = Engine.x86_64.GetPropertyByName(model, "name"), propertyRadius = Engine.x86_64.GetPropertyByName(model, "radius"), propertySegmentationParts = Engine.x86_64.GetPropertyByName(model, "segmentationParts"); // // Instances (creating) // Int64 myInstanceCylinder = Engine.x86_64.CreateInstance(classCylinder, (string) null); double length = 1.8, radius = 1.3; Int64 segmentationParts = 36; Engine.x86_64.SetDatatypeProperty(myInstanceCylinder, propertyLength, ref length, 1); Engine.x86_64.SetDatatypeProperty(myInstanceCylinder, propertyRadius, ref radius, 1); Engine.x86_64.SetDatatypeProperty(myInstanceCylinder, propertySegmentationParts, ref segmentationParts, 1); // // non related / restricted properties (user defined and pre defined) can be connected in any quantity // bool closed = true; string name = "Example text added"; byte closed_inByte = closed ? (byte) 1 : (byte) 0; Engine.x86_64.SetDatatypeProperty(myInstanceCylinder, propertyClosed, ref closed_inByte, 1); Engine.x86_64.SetDatatypeProperty(myInstanceCylinder, propertyName, ref name, 1); System.Diagnostics.Debug.Assert(Engine.x86_64.GetArea(myInstanceCylinder, (IntPtr) 0, (IntPtr) 0) > 0); // // The resulting model can be viewed in 3D-Editor.exe // Engine.x86_64.SaveModel(model, "c:\\created\\myFile.bin"); Engine.x86_64.CloseModel(model); } }