SetObjectProperty

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 givin in the values card.
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 = "SetObjectProperty")]
public static extern Int64 SetObjectProperty(Int64 owlInstance, Int64 rdfProperty, ref Int64 values, Int64 card);    

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 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

Here you can find code snippits that show how the API call SetObjectProperty 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");

        //
        //  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);

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

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

        //
        //  Get Properties
        //

        {
            Int64   card = 0;
            IntPtr  valuesPtr = IntPtr.Zero;
            Engine.x86_64.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;
            Engine.x86_64.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 = 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);

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

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

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

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