1.2: What's New in Karamba3D 1.3.3 Regarding Scripting
The biggest change from Karamba3D 1.3.1 to 1.3.2 is its partial independence from Grasshopper. When taking a look at the contents of the Karamba3D_1_3_3_SDKDoc.chm”-file one sees a list of name-spaces: everything under “Karamba.GHopper” comes with “karamba.gha” and links the C# API of Karamba3D to GH. All the rest resides in “karambaCommon.dll” and can be used independently of Grasshopper and RhinoCommon.dll.
Under “Karamba.Geometry” one finds the geometry types of Karamba3D. In most cases the K3D-equivalents of a GH geometry types come without the “D” at the end: e.g. Grasshopper’s Vector3D is equivalent to K3D’s Vector3. The static class “Karamba.GHopper.Utilities.FromGH” provides typeconversion from GH-wrappes (e.g. GH_Vector) to K3D types. The namespace “Karamba.GHopper.Geometry" contains the classes MeshExtension and MeshExtension which extend the GH and Karamba3D geometry classes with the “Convert” method for bi-directional type conversion.
For nearly all Karamba3D components visible in Grasshopper there is a static class in “karambaCommon.dll” which does the work behind the scenes. Thus one approach would be to use these static classes to manage Karamba3D models. However this makes scripts dependent on the interface definitions of these static classes. In order to provide a more stable API a hierarchy of factories has been implemented. It resides under “KarambaCommon.Factories”. The “Toolkit” class provides access to it and can be used to set up Karamba3D models. An additional advantage of the toolkit consists in the fact that it provides useful default-values for many arguments. Currently not all features of Karamba3D are available via the “Toolkit”. It will however grow in future and constitutes the recommended access point to Karamba3D. Take a look at the Karamba3D unit-test project at https://github.com/karamba3d/K3D_tests to see how this works.