algorithmic modeling for Rhino

Hi Clemens,

I was wondering whether it were possible to change a beam's cross-section using a script in karamba.

I want to use it to run a loop optimization within a custom component.



Views: 392

Replies to This Discussion

Hey Lorenzo,

please have a look at the c# script component in the attached grasshopper definition where I assign a new cross section to the first element of the model. Please read the karamba 1.1.0 Hacker’s Essentials, in particular this sentence: "Before running your script in GH make sure to unhook the Memory load *.GHA assemblies using COFF byte arrays after typing GrasshopperDeveloperSettings in the Rhino text window."




Hi Robert,

Thanks for the script. I had already tried that approach but with a script that also analyzes the model and it seems not to update the crossection afterwards.

Attached is what I get.


Hi Lorenzo,

I understand the problem, but couldn't find a solution. I would also be happy if there were a solution by the Karamba team, I guess it's only one line of code where you update the model completely.

I added line 153 to your script and now the beam elements can refer to a cross section that is known to the model, but that doesn't solve the problem. It's interesting that the stresses are updated in the component whereas the displacements stay the same. When you disassemble and assemble the model again, the cross sections are updated correctly. I am confused...

Another problem I faced is the issue of changing the model upstream in the grasshopper definition. Cloning as discussed here doesn't solve this (


Hi Lorenzo,

the two attached files show how to set up a custom cross section optimizer for beam elements. It should work with Karamba 1.2.2.

'DesignCroSecOpti.cs' contains the abstract base class for custom optimizers. 'DesignCroSecOpti_Simple.cs' shows how to use this in order to implement a simple optimizer.

The code was created in the course of the research project NFormations (see




Hi Clemens,

How exactly are those scripts used in Grasshopper with Karamba?

I'm not sure what to do with those files.



Hi Umar,

this source code is supposed to be used as part of a Visual Studio Project for a Grasshopper plug-in.

For details on how to use Karamba within your scripts see








  • Add Photos
  • View All

© 2019   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service