CreateModel

This function creates and empty model.
References inside to other ontologies will be included. A handle to the model will be returned, or 0 in case something went wrong.

Syntax

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

Example

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