CloseModel

This function closes the model. After this call none of the instances and classes within the model can be used anymore, also garbage collection is not allowed anymore, in default compilation the model itself will be known in the kernel, however known to be disabled. Calls containing the model reference will be protected from crashing when called.

Syntax

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

Here you can find code snippits that show how the API call CloseModel 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);
    }
}