RemoveInstances

This function removes all available instances for the given model from the internal structure.
Return value is the number of removed instances.

Syntax

public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "RemoveInstances")]
public static extern Int64 RemoveInstances(Int64 model);    

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.

Example

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

using Engine;

static void Main(string[] args)
{
    Int64 model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classCube = Engine.x86_64.GetClassByName(model, "Cube"),
                classCylinder = Engine.x86_64.GetClassByName(model, "Cylinder"),
                classMatrix = Engine.x86_64.GetClassByName(model, "Matrix"),
                classTransformation = Engine.x86_64.GetClassByName(model, "Transformation");

        //
        //  Object Properties (relations)
        //
        Int64   propertyMatrix = Engine.x86_64.GetPropertyByName(model, "matrix"),
                propertyObject = Engine.x86_64.GetPropertyByName(model, "object");

        //
        //  Datatype Properties (attributes)
        //
        Int64   property_42 = Engine.x86_64.GetPropertyByName(model, "_42"),
                propertyLength = Engine.x86_64.GetPropertyByName(model, "length"),
                propertyRadius = Engine.x86_64.GetPropertyByName(model, "radius");

        //
        //  Instances (creating)
        //
        Int64   instanceCube = Engine.x86_64.CreateInstance(classCube, (string) null),
                instanceCylinder = Engine.x86_64.CreateInstance(classCylinder, (string) null),
                instanceMatrix = Engine.x86_64.CreateInstance(classMatrix, (string) null),
                instanceTransformation = Engine.x86_64.CreateInstance(classTransformation, (string) null);

        Engine.x86_64.SetObjectProperty(instanceTransformation, propertyObject, ref instanceCylinder, 1);
        Engine.x86_64.SetObjectProperty(instanceTransformation, propertyMatrix, ref instanceMatrix, 1);

        double  lengthCube = 2.1,
                lengthCyl = 2.8,
                radiusCyl = 1.3,
                offsetY = -1.2;

        Engine.x86_64.SetDatatypeProperty(instanceCube, propertyLength, ref lengthCube, 1);
        Engine.x86_64.SetDatatypeProperty(instanceCylinder, propertyLength, ref lengthCyl, 1);
        Engine.x86_64.SetDatatypeProperty(instanceCylinder, propertyRadius, ref radiusCyl, 1);
        Engine.x86_64.SetDatatypeProperty(instanceMatrix, property_42, ref offsetY, 1);

        Int64   instanceCnt = 0;
        Engine.x86_64.OrderedHandles(model, (IntPtr) 0, (IntPtr) 0, out instanceCnt, 0, 0);
        System.Diagnostics.Debug.Assert(instanceCnt == 4);

        Engine.x86_64.RemoveInstances(model);

        Engine.x86_64.OrderedHandles(model, (IntPtr) 0, (IntPtr) 0, out instanceCnt, 0, 0);
        System.Diagnostics.Debug.Assert(instanceCnt == 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);
    }
}