RemoveInstance

This function removes an instance from the internal structure.
In case copies are created by the host this function checks if all copies are removed otherwise the instance will stay available.
Return value is 0 if everything went ok and positive in case of an error

Syntax

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

Here you can find code snippits that show how the API call RemoveInstance 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.RemoveInstance(instanceCylinder); //  this will not remove the Cylinder instance as it is referenced
        Engine.x86_64.RemoveInstance(instanceCube);
        Engine.x86_64.RemoveInstance(instanceMatrix);       //  this will not remove the Cylinder instance as it is referenced  
        Engine.x86_64.OrderedHandles(model, (IntPtr) 0, (IntPtr) 0, out instanceCnt, 0, 0);
        System.Diagnostics.Debug.Assert(instanceCnt == 3);

        Engine.x86_64.RemoveInstance(instanceTransformation);
        Engine.x86_64.OrderedHandles(model, (IntPtr) 0, (IntPtr) 0, out instanceCnt, 0, 0);
        System.Diagnostics.Debug.Assert(instanceCnt == 2);

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