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 (based on pure API calls)

Here you can find code snippits that show how the API call RemoveInstances 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)
    {
        //
        //  Classes
        //
        Int64   classCube = RDF.engine.GetClassByName(model, "Cube"),
                classCylinder = RDF.engine.GetClassByName(model, "Cylinder"),
                classMatrix = RDF.engine.GetClassByName(model, "Matrix"),
                classTransformation = RDF.engine.GetClassByName(model, "Transformation");

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

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

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

        RDF.engine.SetObjectProperty(instanceTransformation, propertyObject, ref instanceCylinder, 1);
        RDF.engine.SetObjectProperty(instanceTransformation, propertyMatrix, ref instanceMatrix, 1);

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

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

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

        RDF.engine.RemoveInstances(model);

        RDF.engine.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
        //
        RDF.engine.SaveModel(model, "c:\\created\\myFile.bin");
        RDF.engine.CloseModel(model);
    }
}