GetObjectProperty

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 given in the value card.
The return value always should be 0, if not something is wrong in the way this property is called.

Syntax

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

[DllImport(enginedll, EntryPoint = "GetObjectProperty")]
public static extern Int64 GetObjectProperty(Int64 owlInstance, Int64 owlObjectProperty, out IntPtr values, out Int64 card);

public static Int64[] GetObjectProperty(Int64 owlInstance, Int64 owlObjectProperty)
        {
            System.Diagnostics.Debug.Assert(GetPropertyType(owlObjectProperty) == OBJECTPROPERTY_TYPE);

            Int64 card = 0;
            IntPtr valuesPtr = IntPtr.Zero;
            GetObjectProperty(owlInstance, owlObjectProperty, out valuesPtr, out card);

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

            return null;
        }    

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 owlObjectProperty

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the object property (relation). 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: 64 bit / 8 byte (reference)
The output array for object properties content. The contents memory is allocated by the library

Property card

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

Example (based on pure API calls)

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

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

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

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classAbcd = RDF.engine.CreateClass(model, "ABCD");

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

        //
        //  Instances
        //
        Int64   instanceAbcdI = RDF.engine.CreateInstance(classAbcd, (string) null),
                instanceAbcdII = RDF.engine.CreateInstance(classAbcd, (string) null);

        //
        //  Set Properties
        //
        
        {
            RDF.engine.SetObjectProperty(instanceAbcdI, propertyAb, ref instanceAbcdII, 1);

            Int64[] valuesAb = { instanceAbcdI, instanceAbcdII, instanceAbcdI };
            RDF.engine.SetObjectProperty(instanceAbcdII, propertyAb, ref valuesAb[0], 3);
        }

        //
        //  Get Properties
        //

        {
            Int64   card = 0;
            IntPtr  valuesPtr = IntPtr.Zero;
            RDF.engine.GetObjectProperty(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;
            RDF.engine.GetObjectProperty(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 = RDF.engine.GetClassByName(model, "Collection"),
                classCube = RDF.engine.GetClassByName(model, "Cube");

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

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

        //
        //  Instances (creating)
        //
        Int64   instanceCollectionI = RDF.engine.CreateInstance(classCollection, (string) null),
                instanceCollectionII = RDF.engine.CreateInstance(classCollection, (string) null),
                instanceCube = RDF.engine.CreateInstance(classCube, (string) null);

        double  length = 1.0;
        
        RDF.engine.SetDatatypeProperty(instanceCube, propertyLength, ref length, 1);

        Int64[] values = { instanceCollectionII, instanceCube, instanceCube };
        RDF.engine.SetObjectProperty(instanceCollectionI, propertyObjects, ref values[0], 3);
        RDF.engine.SetObjectProperty(instanceCollectionII, propertyObjects, ref instanceCube, 1);

        //
        //  CollectionI contains 3 cubes and CollectionII contains 1 cube
        //
        System.Diagnostics.Debug.Assert(RDF.engine.GetVolume(instanceCollectionI, (IntPtr) 0, (IntPtr) 0) == 3);
        System.Diagnostics.Debug.Assert(RDF.engine.GetVolume(instanceCollectionII, (IntPtr) 0, (IntPtr) 0) == 1);

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