CreateClassW

Returns a handle to an on the fly created class.
If the model input is zero or not a model handle 0 will be returned,

Syntax

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

[DllImport(EngineDLL, EntryPoint = "CreateClassW")]
public static extern Int64 CreateClassW(Int64 model, byte[] name);    

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.

Property name

Size: 32 bit / 4 byte (reference)
This attribute represents the name of the class (given as wchar_t array / Unicode). The name is given by the host and the attribute is not changed.

Example

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

using Engine;

static void Main(string[] args)
{
    Int64 model = Engine.x86_64.CreateModel();

    if (model != 0)
    {
        //
        //  The following class will be created on-the-fly if the name is not used already
        //  for a class or property (attribute / relation).
        //
        //  note: calling GetClassByName with a name not yet existing will do the same trick)
        //
        Int64   classMyOwnCylinderClass = Engine.x86_64.CreateClassW(model, System.Text.Encoding.Unicode.GetBytes("MyOwnCylinderClass"));

        //
        //  Classes
        //
        Int64   classCylinder = Engine.x86_64.GetClassByNameW(model, System.Text.Encoding.Unicode.GetBytes("Cylinder"));

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = Engine.x86_64.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("length")),
                propertyRadius = Engine.x86_64.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("radius")),
                propertySegmentationParts = Engine.x86_64.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("segmentationParts"));

        //
        //  Instances
        //
        Int64   instanceMyOwnCylinderClass = Engine.x86_64.CreateInstanceW(classMyOwnCylinderClass, (string) null);

        //
        //  At this moment our new class is unrelated to other classes and instances of it not generating any geometry
        //
        System.Diagnostics.Debug.Assert(Engine.x86_64.GetGeometryClass(classMyOwnCylinderClass) == 0);

        Engine.x86_64.SetClassParent(classMyOwnCylinderClass, classCylinder, 1);

        //
        //  Now each instance of MyOwnCylinderClass is inheriting the behavior and knowledge of a Cylinder
        //
        System.Diagnostics.Debug.Assert(Engine.x86_64.GetGeometryClass(classMyOwnCylinderClass) == classCylinder);

        double  length = 1.8,
                radius = 1.3;
        Int64   segmentationParts = 36;
        
        Engine.x86_64.SetDatatypeProperty(instanceMyOwnCylinderClass, propertyLength, ref length, 1);
        Engine.x86_64.SetDatatypeProperty(instanceMyOwnCylinderClass, propertyRadius, ref radius, 1);
        Engine.x86_64.SetDatatypeProperty(instanceMyOwnCylinderClass, propertySegmentationParts, ref segmentationParts, 1);

        double  volume = Engine.x86_64.GetVolume(instanceMyOwnCylinderClass, (IntPtr) 0, (IntPtr) 0);

        //
        //  The resulting model can be viewed in 3D-Editor.exe
        //
        Engine.x86_64.SaveModelW(model, System.Text.Encoding.Unicode.GetBytes("c:\\created\\myFile.bin"));
        Engine.x86_64.CloseModel(model);
    }
}