Scripting Guide 3.1.4
  • Welcome to Karamba3D Scripting Guide
  • 1. Introduction
    • 1.1: Scripting with Karamba3D
    • 1.2: Basics
  • 2. Scripting with Karamba3D inside Grasshopper
    • 2.1: Hello Karamba3D
    • 2.2: Data Retrieval from Models
    • 2.3: How to Create Structural Models
    • 2.4: How to Modify Structural Models
      • 2.4.1: Cross section Optimization
      • 2.4.2: Activation and Deactivation of Elements
    • 2.5: Data Export from Karamba3D
    • 2.6: The VB Script Component
    • 2.7: The IronPython Component
      • 2.7.1: Results Retrieval on Shells
      • 2.7.2: A Simplified ESO-Procedure on Shells
    • 2.8: The Python 3 Component
      • 2.8.1: Hello Karamba3D
      • 2.8.2: Data Retrieval from Models
      • 2.8.3: How to Create Structural Models
      • 2.8.4: How to Modify Structural Models
        • 2.8.4.1: Cross section Optimization
        • 2.8.4.2: Activation and Deactivation of Elements
  • 3. How to create your own Karamba3D Grasshopper-component
    • 3.1: Setting up a Visual Studio Project for GH Plug-ins
    • 3.2: Basic Component Setup
    • 3.3: How to Reference Karamba3D Assemblies
    • 3.4: Input- and Output-Plugs
    • 3.5: Adding Functionality to a GH Component
  • Bibliography
Powered by GitBook
On this page
  1. 3. How to create your own Karamba3D Grasshopper-component

3.3: How to Reference Karamba3D Assemblies

Previous3.2: Basic Component SetupNext3.4: Input- and Output-Plugs

Last updated 5 months ago

In order to package the script of section into a GH-component there needs to be one input-plug that receives a Karamba3D model. Three output plugs return an updated Karamba3D model, a list of boolean values that signifies which elements are active or not and the value of the largest resultant displacement.

The following example can be found in the examples that accompany this guide. Go to “#/TensionElim” and double-click on “TensionElim.sln” to open the project with Visual Studio. Depending on what version of Grasshopper you use it will be necessary to reestablish the project references.

Referencing Required Libraries: To use Karamba3D classes (e.g., the Model class), you must reference the karambaCommon.dll library. There are two ways to do this:

  • Using the KarambaCommon NuGet Package:

    • In Visual Studio, go to Tools > NuGet Package Manager > Manage NuGet Packages for Solution... and install the KarambaCommon package.

  • Referencing the Installed Library:

    • Right-click References in the Solution Explorer and select Add Reference....

    • In the tabbed view, go to Browse and locate the karambaCommon.dll file in Rhino’s Plug-ins folder.

Including karamba.gha: Since Karamba3D will be used in Grasshopper, you must also reference karamba.gha. However, Visual Studio does not natively allow .gha files to be selected. Use the following workaround:

  • Save and close your Visual Studio project.

  • In the project directory, locate the TensionElim.csproj file and open it in a text editor.

  • Search for the karambaCommon entry, copy it, and modify it to reference karamba.gha (see Fig. 3.3.1 in the guide).

  • Save the file and reopen the project in Visual Studio.

Adjusting Reference Properties:

  • After adding karamba and karambaCommon references, right-click each reference in Solution Explorer and select Properties.

  • Set the Copy Local property (default: True) to False.

Following these steps ensures the script is properly packaged into a custom Grasshopper component for use with Karamba3D.

2.4.2
Fig. 3.3.1: Work-around for referencing "karamba.gha" in Visual Studio: Edit the "TensionElim.csproj"-file