UpdateInstance

This function prepares the content to be ready without filling the buffers as done within CalculateInstance(). CalculateInstance calls this function as a start.
This function will also set the 'derived' values for the instance passed as argument. For example the coordinates values of a MultiplicationMatrix will be set if the array is defined.

Syntax

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

[DllImport(enginedll, EntryPoint = "UpdateInstance")]
public static extern Int64 UpdateInstance(Int64 owlInstance);    

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.

Example (based on pure API calls)

Here you can find code snippits that show how the API call UpdateInstance 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)
    {
        Int64   classInverseMatrix = RDF.engine.GetClassByName(model, "InverseMatrix"),
                classMatrix = RDF.engine.GetClassByName(model, "Matrix");

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

        //
        //  Datatype Properties (attributes)
        //
        Int64   property_21 = RDF.engine.GetPropertyByName(model, "_21"),
                property_33 = RDF.engine.GetPropertyByName(model, "_33"),
                property_42 = RDF.engine.GetPropertyByName(model, "_42");

        //
        //  Instances (creating)
        //
        Int64   instanceInverseMatrix = RDF.engine.CreateInstance(classInverseMatrix, (string) null),
                instanceMatrix = RDF.engine.CreateInstance(classMatrix, (string) null);

        RDF.engine.SetObjectProperty(instanceInverseMatrix, propertyMatrix, ref instanceMatrix, 1);

        double  translationY = 2.8;

        RDF.engine.SetDatatypeProperty(instanceMatrix, property_42, ref translationY, 1);

        Int64   card = 0;
        IntPtr  valuesPtr = IntPtr.Zero;
        RDF.engine.GetDatatypeProperty(instanceMatrix, property_21, out valuesPtr, out card);
        System.Diagnostics.Debug.Assert(card == 0);

        RDF.engine.GetDatatypeProperty(instanceMatrix, property_33, out valuesPtr, out card);
        System.Diagnostics.Debug.Assert(card == 0);

        RDF.engine.GetDatatypeProperty(instanceInverseMatrix, property_42, out valuesPtr, out card);
        System.Diagnostics.Debug.Assert(card == 0);

        RDF.engine.GetDatatypeProperty(instanceInverseMatrix, property_33, out valuesPtr, out card);
        System.Diagnostics.Debug.Assert(card == 0);

        //
        //  Force to apply a calculation of the tree,
        //  CalculateInstance without further non-zero arguments has the same effect.
        //
        RDF.engine.UpdateInstance(instanceInverseMatrix);

        //
        //  Assign all implicitely known values
        //
        RDF.engine.InferenceInstance(instanceInverseMatrix);

        RDF.engine.GetDatatypeProperty(instanceMatrix, property_21, out valuesPtr, out card);
        System.Diagnostics.Debug.Assert(card == 1);
        if (card > 0)
        {
            double[] values = new double[card];
            System.Runtime.InteropServices.Marshal.Copy(valuesPtr, values, 0, (int) card);
            System.Diagnostics.Debug.Assert(values[0] == 0.0);
        }

        RDF.engine.GetDatatypeProperty(instanceMatrix, property_33, out valuesPtr, out card);
        System.Diagnostics.Debug.Assert(card == 1);
        if (card > 0)
        {
            double[] values = new double[card];
            System.Runtime.InteropServices.Marshal.Copy(valuesPtr, values, 0, (int) card);
            System.Diagnostics.Debug.Assert(values[0] == 1.0);
        }

        RDF.engine.GetDatatypeProperty(instanceInverseMatrix, property_42, out valuesPtr, out card);
        System.Diagnostics.Debug.Assert(card == 1);
        if (card > 0)
        {
            double[] values = new double[card];
            System.Runtime.InteropServices.Marshal.Copy(valuesPtr, values, 0, (int) card);
            System.Diagnostics.Debug.Assert(values[0] == -translationY);
        }

        RDF.engine.GetDatatypeProperty(instanceInverseMatrix, property_33, out valuesPtr, out card);
        System.Diagnostics.Debug.Assert(card == 1);
        if (card > 0)
        {
            double[] values = new double[card];
            System.Runtime.InteropServices.Marshal.Copy(valuesPtr, values, 0, (int) card);
            System.Diagnostics.Debug.Assert(values[0] == 1.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);
    }
}