SetObjectPropertyEx

This function sets the value(s) of a certain objectTypeProperty 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 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 SetObjectProperty, however needs to be used in case properties are exchanged as a successive series of integers.

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 = "SetObjectPropertyEx")]
public static extern Int64 SetObjectPropertyEx(Int64 model, Int64 owlInstance, Int64 owlObjectProperty, ref Int64 values, Int64 card);

[DllImport(enginedll, EntryPoint = "SetObjectPropertyEx")]
public static extern Int64 SetObjectPropertyEx(Int64 model, Int64 owlInstance, Int64 owlObjectProperty, Int64[] values, 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 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: 32 bit / 4 byte (reference)
The input array for object properties content. The contents memory is allocated by the host

Property card

Size: 64 bit / 8 byte (value)
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 SetObjectPropertyEx 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)
    {
        //
        //  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 = 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);
        System.Diagnostics.Debug.Assert(instanceAbcdI == instanceCnt + 1);
        System.Diagnostics.Debug.Assert(instanceAbcdII == instanceCnt + 2);

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

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

        //
        //  Get Properties
        //

        {
            Int64   card = 0;
            IntPtr  valuesPtr = IntPtr.Zero;
            RDF.engine.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;
            RDF.engine.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 = 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);
        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;
        
        RDF.engine.SetDatatypePropertyEx(model, instanceCube, propertyLength, ref length, 1);

        Int64[] values = { instanceCollectionII, instanceCube, instanceCube };
        RDF.engine.SetObjectPropertyEx(model, instanceCollectionI, propertyObjects, ref values[0], 3);
        RDF.engine.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
        //
        RDF.engine.SaveModel(model, "c:\\created\\myFile.bin");
        RDF.engine.CloseModel(model);
    }
}