GetInstancesByIterator

Returns a handle to an instance.
If input instance is zero, the handle will point to the first relevant instance.
If all instances are past (or no relevant instances are found), the function will return 0.

Syntax

public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "GetInstancesByIterator")]
public static extern Int64 GetInstancesByIterator(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

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

using Engine;

public Int64 GetInstanceCnt(Int64 model)
{
    Int64   instanceCnt = 0,
            myIteratedInstance = Engine.x86_64.GetInstancesByIterator(model, 0);
    while (myIteratedInstance != 0) {
        IntPtr    instanceNamePtr = IntPtr.Zero;
        Engine.x86_64.GetNameOfInstance(myIteratedInstance, out instanceNamePtr);
        string instanceName = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(instanceNamePtr);
        Console.WriteLine(instanceName);
        IntPtr    classNamePtr = IntPtr.Zero;
        Engine.x86_64.GetNameOfClass(Engine.x86_64.GetInstanceClass(myIteratedInstance), out classNamePtr);
        string className = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(classNamePtr);
        Console.WriteLine(className);
        myIteratedInstance = Engine.x86_64.GetInstancesByIterator(model, myIteratedInstance);
        instanceCnt++;
    }
    Console.WriteLine();

    return  instanceCnt;
}

public void Example()
{
    Int64 model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        Int64   instanceCnt = GetInstanceCnt(model);

        //
        //  Add a new instance
        //
        Engine.x86_64.CreateInstance(Engine.x86_64.GetClassByName(model, "Collection"), "CreatedInstanceToTestInstanceCnt");

        System.Diagnostics.Debug.Assert(GetInstanceCnt(model) == instanceCnt + 1);

        Int64   instanceCntThroughAPI = 0;
        Engine.x86_64.OrderedHandles(model, (IntPtr) null, (IntPtr) null, out instanceCntThroughAPI, 0, 0);

        System.Diagnostics.Debug.Assert(GetInstanceCnt(model) == instanceCntThroughAPI);

        Engine.x86_64.CloseModel(model);
    }
}