# 1.1: Scripting with Karamba3D

Sometimes when creating a Grasshopper (GH) definition you may reach a point where it makes sense to switch from GH’s visual computing environment to textual scripting. This is e.g. the case if you want to apply loops, functions or more refined object oriented programming concepts. Other points in favor of a textual approach would be debugging or code reuse.

When installed for Grasshopper Karamba3D consists of three main parts (these files reside in the “Plug-ins”-folder of Rhino - typically ***C:\ProgramFiles\Rhino6\Plug-ins\Karamba\\***.):

* **“karamba.dll”** is a C++ library which does the numeric calculations.&#x20;
* **“karambaCommon.dll”** provides the .NET user interface to the Karamba3D functionality. It features its own set of geometric types (e.g. vectors, points, meshes,. . . ) and is therefore independent from Grasshopper or Rhino.&#x20;
* **“karamba.gha”** connects GH to **“karambaCommon.dll”** and takes care of the graphical user- interface.&#x20;

This scripting guide comes with a help-file (**“Karamba3D\_1\_3\_3\_SDKDoc.chm”** also accessible online [Karamba3D 1.3.3 SDK Documentation](https://karamba3d.com/help/1-3-3)) which covers **“karambaCommon.dll”** and parts of **“karamba.gha”**. It can be found in the “[Karamba3D Scripting Examples Github](https://github.com/karamba3d/K3D_Scripting)”-collection which accompanies this manual. A useful additional source of information regarding scripting with Karamba3D are the **“karambaCommon.dll”**- and **“karamba.gha”** files themselves: Feel free to use a tool like **“ILSpy”** to decompile them and have a look at their inner workings.

The main incentive behind decoupling K3D from Grasshopper was to enable Unit-testing for the C# application programming interface (API) of Karamba3D and thus enhance its code quality. You can download the Karamba3D test-project from <https://github.com/karamba3d/K3D_tests>. The test cases represent code-snippets which show how to work with the Karamba3D API and form another useful source of know-how regarding C# of K3D.

Karamba3D is work in progress. So are its interface definitions. Be aware of the fact, that they will probably change in future.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://scripting-2.karamba3d.com/1.introduction/1.1-scripting-with-karamba3d.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
