GetInstanceClassEx

Returns the handle to the class of which the instance is instantiated. In case the instance is instantiated on more than one class it will return 0.

Syntax

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

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

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.

Example (based on pure API calls)

Here you can find code snippits that show how the API call GetInstanceClassEx 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 class handled 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.
        //
        Engine.x86_64.OrderedHandles(model, (IntPtr) null, (IntPtr) null, (IntPtr) null, 1 + 2 + 4, 1 + 2 + 4);

        //
        //  Classes
        //
        Int64   classAbcd = RDF.engine.CreateClass(model, "ABCD"),
                classCube = RDF.engine.CreateClass(model, "Cube"),
                classMatrix = RDF.engine.CreateClass(model, "Matrix");

        //
        //  Instances
        //
        Int64   instanceAbcd = RDF.engine.CreateInstanceEx(model, classAbcd, (string) null),
                instanceCube = RDF.engine.CreateInstanceEx(model, classCube, (string) null),
                instanceMatrixI = RDF.engine.CreateInstanceEx(model, classMatrix, (string) null),
                instanceMatrixII = RDF.engine.CreateInstanceEx(model, classMatrix, (string) null);

        System.Diagnostics.Debug.Assert(RDF.engine.GetInstanceClassEx(model, instanceAbcd) == classAbcd);
        System.Diagnostics.Debug.Assert(RDF.engine.GetInstanceClassEx(model, instanceCube) == classCube);
        System.Diagnostics.Debug.Assert(RDF.engine.GetInstanceClassEx(model, instanceMatrixI) == RDF.engine.GetInstanceClassEx(model, instanceMatrixII));

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