# 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:

* **“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;

These files reside in the installation folder of Karamba3D. Their location depends on the chosen installation method:

* **Installation via MSI Installer**\
  Files are located in Rhino's “Plug-ins” folder. The default path is:\
  `C:\Program Files\Rhino 8\Plug-ins\Karamba\`
* **Installation via Package Manager (YAK)**\
  Files are installed in the following folder:\
  `C:\Users\<YourUsername>\AppData\Roaming\McNeel\Rhinoceros\packages\8.0\Karamba3D\3.1.40918`\
  \&#xNAN;*(Example shown for version 3.1.40918)*\
  To access this folder quickly, use the file explorer and enter `%appdata%` to navigate to the "Roaming" folder.

Alternatively, the Karamba3D NuGet package can be used to integrate the functionality of **karambaCommon** (refer to documentation \[[here](https://www.nuget.org/packages/KarambaCommon/)]). This method is utilized in the [**K3D\_tests**](https://github.com/karamba3d/K3D_tests) project.

**API Documentation and Additional Resources**

* **API Documentation**: The Karamba3D API documentation is available at <https://www.karamba3d.com/help/3-1-4>.
* **Exploring Code**: The `karambaCommon.dll` and `karamba.gha` files can be inspected using tools like “ILSpy” to decompile and analyze their functionality.

**Purpose of Decoupling from Grasshopper**

Decoupling Karamba3D (K3D) from Grasshopper was primarily aimed at enabling unit testing for its C# application programming interface (API) to improve code quality.

* **Test Project**: The Karamba3D test project can be downloaded from <https://github.com/karamba3d/K3D_tests>.\
  The test cases include code snippets demonstrating API usage, serving as a valuable learning resource for working with the Karamba3D C# API.

**Notes on Development and Interface Stability**

Karamba3D is under active development, and its interface definitions are subject to change in future releases. Users should account for potential updates when working with the API.


---

# 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.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.
