GetClassByNameW

Returns a handle to the class as stored inside.
When the class does not exist yet and the name is unique the class will be created on the fly and the handle will be returned.
When the name is not unique and given to an instance, objectTypeProperty or dataTypeProperty 0 will be returned.

Syntax

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

[DllImport(EngineDLL, EntryPoint = "GetClassByNameW")]
public static extern Int64 GetClassByNameW(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 GetClassByNameW can be used.

using Engine;

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

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   classArc3D = Engine.x86_64.GetClassByNameW(model, System.Text.Encoding.Unicode.GetBytes("Arc3D"));

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

        //
        //  Instances (creating)
        //
        Int64   myInstanceArc3D = Engine.x86_64.CreateInstanceW(classArc3D, (string) null);

        double  Pi = 2.0 * Math.Acos(0.0),
                radius = 2.1,
                start = 0.0,
                size = 2.0 * Pi;
        Int64   segmentationParts = 36;
        
        Engine.x86_64.SetDatatypeProperty(myInstanceArc3D, propertyRadius, ref radius, 1);
        Engine.x86_64.SetDatatypeProperty(myInstanceArc3D, propertyStart, ref start, 1);      //  in this case we could also do without, i.e. default value
        Engine.x86_64.SetDatatypeProperty(myInstanceArc3D, propertySize, ref size, 1);        //  in this case we could also do without, i.e. default value
        Engine.x86_64.SetDatatypeProperty(myInstanceArc3D, propertySegmentationParts, ref segmentationParts, 1);

        //
        //  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);
    }
}