SetNameOfClass

Sets/updates the name of the class, if no error it returns 0.
In case class does not exist it returns 1, when name cannot be updated 2.

Syntax

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

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

Property owlClass

Size: 64 bit / 8 byte (value)
This attribute represents a handle to the class. The term owl is comming from W3C, the classes follow the expression power of Semantic Web concepts, therefore classes support multiple inheritance. Technically classes can also be distributed over different resources, however for this the parametric library is required as an extension on the basic Geometry Kernel API.

Property name

Size: 64 bit / 8 byte (reference)
This attribute represents the name of the class (given as char array / ASCII). 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 SetNameOfClass can be used.

using Engine;

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

    if (model != 0)
    {
        //
        //  Classes
        //
        Int64   myClass = Engine.x86_64.CreateClass(model, "MyCreatedClass");

        //
        //  Datatype Properties (attributes)
        //
        Int64   propertyLength = Engine.x86_64.GetPropertyByName(model, "length");

        //
        //  Instances (creating)
        //
        Int64   myInstance = Engine.x86_64.CreateInstance(myClass, (string) null);

        double  length = 2.0;

        Engine.x86_64.SetDatatypeProperty(myInstance, propertyLength, ref length, 1);

        System.Diagnostics.Debug.Assert(Engine.x86_64.GetVolume(myInstance, (IntPtr) 0, (IntPtr) 0) == 0.0);

        IntPtr  classNamePtrI = IntPtr.Zero;
        Engine.x86_64.GetNameOfClass(myClass, out classNamePtrI);
        string classNameI = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(classNamePtrI);

        Engine.x86_64.SetNameOfClass(myClass, "OtherClassName");

        IntPtr  classNamePtrII = IntPtr.Zero;
        Engine.x86_64.GetNameOfClass(myClass, out classNamePtrII);
        string classNameII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(classNamePtrII);

        Engine.x86_64.SetClassParent(myClass, Engine.x86_64.GetClassByName(model, "Cube"), 1);

        System.Diagnostics.Debug.Assert(Engine.x86_64.GetVolume(myInstance, (IntPtr) 0, (IntPtr) 0) == 8.0);

        Engine.x86_64.SetNameOfClass(myClass, "OutOfIdeasForClassName");

        IntPtr  classNamePtrIII = IntPtr.Zero;
        Engine.x86_64.GetNameOfClass(myClass, out classNamePtrIII);
        string classNameIII = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(classNamePtrIII);

        //
        //  The retrieved class names have the following values 
        //      classNameI   :  'MyCreatedClass'
        //      classNameII  :  'OtherClassName'
        //      classNameIII :  'OutOfIdeasForClassName'
        //

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