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

//   Visual Studio for Windows
public:
__int64 __declspec(dllexport) __stdcall RemoveInstance(
            __int64             owlInstance
        );

//   Linux, OS-X and non-Visual Studio Windows solutions
public:
int64_t RemoveInstance(
            int64_t             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.

int64_t model = CreateModel();

if (model) {
    //
    //  Classes
    //
    int64_t classCube = GetClassByName(model, "Cube"),
            classCylinder = GetClassByName(model, "Cylinder"),
            classMatrix = GetClassByName(model, "Matrix"),
            classTransformation = GetClassByName(model, "Transformation");

    //
    //  Object Properties (relations)
    //
    int64_t propertyMatrix = GetPropertyByName(model, "matrix"),
            propertyObject = GetPropertyByName(model, "object");

    //
    //  Datatype Properties (attributes)
    //
    int64_t property_42 = GetPropertyByName(model, "_42"),
            propertyLength = GetPropertyByName(model, "length"),
            propertyRadius = GetPropertyByName(model, "radius");

    //
    //  Instances (creating)
    //
    int64_t instanceCube = CreateInstance(classCube, nullptr),
            instanceCylinder = CreateInstance(classCylinder, nullptr),
            instanceMatrix = CreateInstance(classMatrix, nullptr),
            instanceTransformation = CreateInstance(classTransformation, nullptr);

    SetObjectProperty(instanceTransformation, propertyObject, &instanceCylinder, 1);
    SetObjectProperty(instanceTransformation, propertyMatrix, &instanceMatrix, 1);

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

    SetDatatypeProperty(instanceCube, propertyLength, &lengthCube, 1);
    SetDatatypeProperty(instanceCylinder, propertyLength, &lengthCyl, 1);
    SetDatatypeProperty(instanceCylinder, propertyRadius, &radiusCyl, 1);
    SetDatatypeProperty(instanceMatrix, property_42, &offsetY, 1);

    int64_t instanceCnt = 0;
    OrderedHandles(model, nullptr, nullptr, &instanceCnt, 0, 0);
    assert(instanceCnt == 4);

    RemoveInstance(instanceCylinder);   //  this will not remove the Cylinder instance as it is referenced
    RemoveInstance(instanceCube);
    RemoveInstance(instanceMatrix);     //  this will not remove the Cylinder instance as it is referenced  
    OrderedHandles(model, nullptr, nullptr, &instanceCnt, 0, 0);
    assert(instanceCnt == 3);

    RemoveInstance(instanceTransformation);
    OrderedHandles(model, nullptr, nullptr, &instanceCnt, 0, 0);
    assert(instanceCnt == 2);

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