Scripting Guide v2
  • Welcome to Karamba3D Scripting Guide
  • Go to Scripting Guide 1.3.3
  • Go to Manual
  • 1. Introduction
    • 1.1: Scripting with Karamba3D
    • 1.2: What's New in Karamba3D 1.3.3 Regarding Scripting
  • 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
  • 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

Was this helpful?

  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 4 years ago

Was this helpful?

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.

The first step consists in referencing the “karambaCommon.dll”-library so that Karamba3D-classes (such as the Model-class) can be dealt with. For this right-click on “References” in the “Solution Explorer” select “Add Reference...” from the context menu and go to “Browse” on the tabbed view and point to “karambaCommon.dll” in the Rhino “Plug-ins”-folder. Since Karmba3D shall be used within Grasshopper, one needs to include “karamba.gha” as well. Alas by default Visual Studio does not allow the selection of files with extension “.gha”.

As a work-around do the following: Save and close your Visual Studio project. In the project directory you will find a file called “TensionElim.csproj”. Open it with a text editor, search for “karambaCommon”, copy its entry, fill in “karamba.gha” (see fig. 3.3.1), save it and reopen the Visual Studio project.

Now right-click on the “karamba” and “karambaCommon”-entries in “References” and select “Properties” from the context menu. Set the property “Copy Local” (it has the value true by default) to false.

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