SaveInstanceTree

This function saves the selected instance and its dependancies on location file name.

Syntax

//
//   Strong typing definition
//
int64_t         SaveInstanceTree(
                        OwlInstance             owlInstance,
                        const char              * fileName
                    );

static  inline  int64_t SaveInstanceTree(
                                OwlInstance             owlInstance,
                                char                    * fileName
                            )
{
    return  SaveInstanceTree(
                    owlInstance,
                    (const char*) fileName
                );
}


//
//   Weak typing definition
//
int64_t __declspec(dllexport) __stdcall SaveInstanceTree(
                                                int64_t                 owlInstance,
                                                const char              * fileName
                                            );

static  inline  int64_t SaveInstanceTree(
                                int64_t                 owlInstance,
                                char                    * fileName
                            )
{
    return  SaveInstanceTree(
                    owlInstance,
                    (const char*) fileName
                );
}
    

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.

Property fileName

Size: 32 bit / 4 byte (reference)
The file name of the file as available in the file system in ASCII (char *). The given char array will not be adjusted, on each OS the size of a char element is 8 bit / 1 byte.

Example (based on pure API calls)

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

#include    "./include/engine.h"
#include    <assert.h>

void    CreateContent()
{
    int64_t model = CreateModel();

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

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

        //
        //  Datatype Properties (attributes)
        //
        int64_t property_41 = GetPropertyByName(model, "_41"),
                propertyLength = GetPropertyByName(model, "length"),
                propertyRadius = GetPropertyByName(model, "radius"),
                propertySegmentationParts = GetPropertyByName(model, "segmentationParts"),
                propertyType = GetPropertyByName(model, "type");

        //
        //  Instances
        //
        int64_t instanceBooleanOperation = CreateInstance(classBooleanOperation, nullptr),
                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  length = 1.8,
                radius = 1.3,
                offsetX = 4.2;
        int64_t segmentationParts = 36;
        
        SetDatatypeProperty(instanceCylinder, propertyLength, &length, 1);
        SetDatatypeProperty(instanceCylinder, propertyRadius, &radius, 1);
        SetDatatypeProperty(instanceCylinder, propertyFirstObject, &segmentationParts, 1);
        SetDatatypeProperty(instanceMatrix, property_41, &offsetX, 1);

        //
        //  Saves only the Transformation and (indirectly) related instances
        //
        SaveInstanceTree(instanceTransformation, "c:\\created\\TranformedCylinder.bin");

        SetObjectProperty(instanceBooleanOperation, propertyFirstObject, &instanceCube, 1);
        SetObjectProperty(instanceBooleanOperation, propertySecondObject, &instanceCylinder, 1);

        length = 2.1;
        int64_t type = 1;

        SetDatatypeProperty(instanceCube, propertyLength, &length, 1);
        SetDatatypeProperty(instanceBooleanOperation, propertyType, &type, 1);

        //
        //  Saves all instances
        //
        SaveModel(model, "c:\\created\\TranformedCylinderAndCubeWithSubtractedCylinder.bin");

        //
        //  Saves only the Boolean Operation and (indirectly) related instances
        //
        SaveInstanceTree(instanceBooleanOperation, "c:\\created\\CubeWithSubtractedCylinder.bin");

        CloseModel(model);
    }
}