GetObjectPropertyEx

This function gets the value(s) of a certain objectProperty in the context of an instance.
The value of card gives the actual card of the values list.
The list values of integers is a list of handles to instances, this list has a length as givin in the values card.
The return value always should be 0, if not something is wrong in the way this property is called.

This call has the same behavior as GetObjectProperty, however needs to be used in case properties are exchanged as a successive series of integers.

Syntax

public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "GetObjectPropertyEx")]
public static extern Int64 GetObjectPropertyEx(Int64 model, Int64 owlInstance, Int64 rdfProperty, out IntPtr values, out Int64 card);    

Property model

Size: 64 bit / 8 byte (value)
The handle to the model. The model handle is static during its existance. Several models can be opened simultaniously within one session. Different models are always independent, threads are allowed to be running on different models simultaniously.

Property owlInstance

Size: 64 bit / 8 byte (value)
The handle to the specific instance in the design tree. The instance handle is static within one open model but is most probably different when the same instance is opened in another model. The instance is always exactly of one unique class.

Property rdfProperty

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the property, this can be either a datatype property (attribute), an object property (relation) or non-defined property. The handle will be static during the life-time of the model, when the model (or part of it) is saved and opened again, the handle will most probably be different.

Property values

Size: 32 bit / 4 byte (reference)
The output array for object properties content. The contents memory is allocated by the library

Property card

Size: 32 bit / 4 byte (reference)
The cardinality (i.e. number of elements) of the array as given or returned.

Example

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

using Engine;

static void Main(string[] args)
{
    Int64 model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        //
        //  The following setting makes sure all instance handles are in an ordered list
        //  In certain cases where several models are open or in case of conversion
        //  between formats this can be handy and / or time efficient.
        //
        Int64   instanceCnt = 0;
        Engine.x86_64.OrderedHandles(model, (IntPtr) 0, (IntPtr) 0, out instanceCnt, 4, 4);
        System.Diagnostics.Debug.Assert(instanceCnt == 0);

        //
        //  Classes
        //
        Int64   classAbcd = Engine.x86_64.CreateClass(model, "ABCD");

        //
        //  Object Properties (relations)
        //
        Int64   propertyAb = Engine.x86_64.CreateProperty(model, Engine.x86_64.OBJECTPROPERTY_TYPE, "Ab");

        //
        //  Instances
        //
        Int64   instanceAbcdI = Engine.x86_64.CreateInstance(classAbcd, (string) null),
                instanceAbcdII = Engine.x86_64.CreateInstance(classAbcd, (string) null);
        System.Diagnostics.Debug.Assert(instanceAbcdI == instanceCnt + 1);
        System.Diagnostics.Debug.Assert(instanceAbcdII == instanceCnt + 2);

        //
        //  Set Properties
        //
        
        {
            Engine.x86_64.SetObjectPropertyEx(model, instanceAbcdI, propertyAb, ref instanceAbcdII, 1);

            Int64[] valuesAb = { instanceAbcdI, instanceAbcdII, instanceAbcdI };
            Engine.x86_64.SetObjectPropertyEx(model, instanceAbcdII, propertyAb, ref valuesAb[0], 3);
        }

        //
        //  Get Properties
        //

        {
            Int64   card = 0;
            IntPtr  valuesPtr = IntPtr.Zero;
            Engine.x86_64.GetObjectPropertyEx(model, instanceAbcdI, propertyAb, out valuesPtr, out card);

            System.Diagnostics.Debug.Assert(card == 1);

            if (card > 0)
            {
                Int64[] valuesAb = new Int64[card];
                System.Runtime.InteropServices.Marshal.Copy(valuesPtr, valuesAb, 0, (int) card);

                System.Diagnostics.Debug.Assert(valuesAb[0] == instanceAbcdII);
            }
        }

        {
            Int64   card = 0;
            IntPtr  valuesPtr = IntPtr.Zero;
            Engine.x86_64.GetObjectPropertyEx(model, instanceAbcdII, propertyAb, out valuesPtr, out card);

            System.Diagnostics.Debug.Assert(card == 3);

            if (card > 0)
            {
                Int64[] valuesAb = new Int64[card];
                System.Runtime.InteropServices.Marshal.Copy(valuesPtr, valuesAb, 0, (int) card);

                System.Diagnostics.Debug.Assert(valuesAb[0] == instanceAbcdI && valuesAb[1] == instanceAbcdII && valuesAb[2] == instanceAbcdI);
            }
        }

        //
        //  The same can be applied to existing classes and properties
        //

        //
        //  Classes
        //
        Int64   classCollection = Engine.x86_64.GetClassByName(model, "Collection"),
                classCube = Engine.x86_64.GetClassByName(model, "Cube");

        //
        //  Object Properties (relations)
        //
        Int64   propertyObjects = Engine.x86_64.GetPropertyByName(model, "objects");

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = Engine.x86_64.GetPropertyByName(model, "length");

        //
        //  Instances (creating)
        //
        Int64   instanceCollectionI = Engine.x86_64.CreateInstance(classCollection, (string) null),
                instanceCollectionII = Engine.x86_64.CreateInstance(classCollection, (string) null),
                instanceCube = Engine.x86_64.CreateInstance(classCube, (string) null);
        System.Diagnostics.Debug.Assert(instanceCollectionI == instanceCnt + 3);
        System.Diagnostics.Debug.Assert(instanceCollectionII == instanceCnt + 4);
        System.Diagnostics.Debug.Assert(instanceCube == instanceCnt + 5);

        double  length = 1.0;
        
        Engine.x86_64.SetDatatypePropertyEx(model, instanceCube, propertyLength, ref length, 1);

        Int64[] values = { instanceCollectionII, instanceCube, instanceCube };
        Engine.x86_64.SetObjectPropertyEx(model, instanceCollectionI, propertyObjects, ref values[0], 3);
        Engine.x86_64.SetObjectPropertyEx(model, instanceCollectionII, propertyObjects, ref instanceCube, 1);

        //
        //  CollectionI contains 3 cubes and CollectionII contains 1 cube
        //

        //
        //  The resulting model can be viewed in 3D-Editor.exe
        //
        Engine.x86_64.SaveModel(model, "c:\\created\\myFile.bin");
        Engine.x86_64.CloseModel(model);
    }
}