SaveInstanceTreeW

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

Syntax

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

[DllImport(EngineDLL, EntryPoint = "SaveInstanceTreeW")]
public static extern Int64 SaveInstanceTreeW(Int64 owlInstance, byte[] 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 Unicode (wchar_t *). The given wchar_t array will not be adjusted. The size of each wchar_t element is depending on the OS, both 16 bit / 2 bytes wchar_t elements as well as 32 bit / 4 byte wchar_t elements are recognized and supported.

Example

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

using Engine;

...

public void CreateContent()
{
    Int64   model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classBooleanOperation = Engine.x86_64.GetClassByName(model, "BooleanOperation"),
                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   propertyFirstObject = Engine.x86_64.GetPropertyByName(model, "firstObject"),
                propertyMatrix = Engine.x86_64.GetPropertyByName(model, "matrix"),
                propertyObject = Engine.x86_64.GetPropertyByName(model, "object"),
                propertySecondObject = Engine.x86_64.GetPropertyByName(model, "secondObject");

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

        //
        //  Instances
        //
        Int64   instanceBooleanOperation = Engine.x86_64.CreateInstance(classBooleanOperation, (string) null),
                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  length = 1.8,
                radius = 1.3,
                offsetX = 4.2;
        Int64   segmentationParts = 36;
        
        Engine.x86_64.SetDatatypeProperty(instanceCylinder, propertyLength, ref length, 1);
        Engine.x86_64.SetDatatypeProperty(instanceCylinder, propertyRadius, ref radius, 1);
        Engine.x86_64.SetDatatypeProperty(instanceCylinder, propertyFirstObject, ref segmentationParts, 1);
        Engine.x86_64.SetDatatypeProperty(instanceMatrix, property_41, ref offsetX, 1);

        //
        //  Saves only the Transformation and (indirectly) related instances
        //
        Engine.x86_64.SaveInstanceTreeW(instanceTransformation, System.Text.Encoding.Unicode.GetBytes("c:\\created\\TranformedCylinder.bin"));

        Engine.x86_64.SetObjectProperty(instanceBooleanOperation, propertyFirstObject, ref instanceCube, 1);
        Engine.x86_64.SetObjectProperty(instanceBooleanOperation, propertySecondObject, ref instanceCylinder, 1);

        length = 2.1;
        Int64   type = 1;

        Engine.x86_64.SetDatatypeProperty(instanceCube, propertyLength, ref length, 1);
        Engine.x86_64.SetDatatypeProperty(instanceBooleanOperation, propertyType, ref type, 1);

        //
        //  Saves all instances
        //
        Engine.x86_64.SaveModelW(model, System.Text.Encoding.Unicode.GetBytes("c:\\created\\TranformedCylinderAndCubeWithSubtractedCylinder.bin"));

        //
        //  Saves only the Boolean Operation and (indirectly) related instances
        //
        Engine.x86_64.SaveInstanceTreeW(instanceBooleanOperation, System.Text.Encoding.Unicode.GetBytes("c:\\created\\CubeWithSubtractedCylinder.bin"));

        Engine.x86_64.CloseModel(model);
    }
}