CreateClassW
a class with this name already exists the handle of existing class will be returned.
The following reasons will cause a return value of 0:
- when the name is already used for an instance or property;
- if the model input is zero or not a model handle.
Giving the class a name is optional, if a name is not given it will recieve an automatically generated name,
it's automatically generated name can change between sessions.
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)Property name
Size: 32 bit / 4 byte (reference)
Example (based on pure API calls)
Here you can find code snippits that show how the API call CreateClassW can be used.
using RDF; // include at least engine.cs within your solution static void Main(string[] args) { Int64 model = RDF.engine.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 = RDF.engine.CreateClassW(model, System.Text.Encoding.Unicode.GetBytes("MyOwnCylinderClass")); // // Classes // Int64 classCylinder = RDF.engine.GetClassByNameW(model, System.Text.Encoding.Unicode.GetBytes("Cylinder")); // // Datatype Properties (attributes) // Int64 propertyLength = RDF.engine.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("length")), propertyRadius = RDF.engine.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("radius")), propertySegmentationParts = RDF.engine.GetPropertyByNameW(model, System.Text.Encoding.Unicode.GetBytes("segmentationParts")); // // Instances // Int64 instanceMyOwnCylinderClass = RDF.engine.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(RDF.engine.GetGeometryClass(classMyOwnCylinderClass) == 0); RDF.engine.SetClassParent(classMyOwnCylinderClass, classCylinder, 1); // // Now each instance of MyOwnCylinderClass is inheriting the behavior and knowledge of a Cylinder // System.Diagnostics.Debug.Assert(RDF.engine.GetGeometryClass(classMyOwnCylinderClass) == classCylinder); double length = 1.8, radius = 1.3; Int64 segmentationParts = 36; RDF.engine.SetDatatypeProperty(instanceMyOwnCylinderClass, propertyLength, ref length, 1); RDF.engine.SetDatatypeProperty(instanceMyOwnCylinderClass, propertyRadius, ref radius, 1); RDF.engine.SetDatatypeProperty(instanceMyOwnCylinderClass, propertySegmentationParts, ref segmentationParts, 1); double volume = RDF.engine.GetVolume(instanceMyOwnCylinderClass, (IntPtr) 0, (IntPtr) 0); // // The resulting model can be viewed in 3D-Editor.exe // RDF.engine.SaveModelW(model, System.Text.Encoding.Unicode.GetBytes("c:\\created\\myFile.bin")); RDF.engine.CloseModel(model); } }