Grasshopper

algorithmic modeling for Rhino

Changing multiple beam cross-sections with c# karamba scripting

Hello all,

I've had a look at this thread:

http://www.grasshopper3d.com/group/karamba/forum/topics/change-beam... 

but I'd like to expand the script so that it would accept a list of diameters for my Karamba model.

My model is a simple compression test of a randomly generated structure. I have a new list of diameters I've generated for each beam element in my model that I'd like to use to update the karamba model.

Some of the beams have specific beam ID's and I'd like the C# script to recognise this and modify the value in the list before applying it as a beam diameter.

I'm not particularly familiar with C# coding so apologies if the answer is simple. 


Thanks for your help!

Best,
Umar

Views: 385

Attachments:

Replies to This Discussion

Hello Umar,

I am not sure, but is this what you want to achieve: For groups of beams with identical identifiers a list of circular cross sections exists and it should be possible that an arbitrary item of this cross section list can be selected for the resulting model.

This could be done by preparing a list of circular cross sections in Grasshopper and then using a script to filter out those cross sections which shall be fed into the Assemble-component to generate the model.

Best,

Clemens

Hello Clemens,

Yes that's pretty much what I would like. I think my issue is in the C# scripting itself, which I'm not that familiar with.

For example, in the C# component in the definition I posted (which is from the other thread), the important line is:

inputModel.elems[0].crossection = new Karamba.CrossSections.CroSec_Circle("Pipes", "Small pipe", "GER", newDiameter, 0.5);

which assigns only the first element (inputModel.elems[0].crossection) the new cross section. Could you give me an example of what this line might look like using lists? Again, I'm really unfamiliar with C# coding.

Otherwise, if you could point me in the direction of a good resource for this kind of thing I'd be really grateful.

Best,
Umar

Hello Umar,

in order to assign a new cross section to all element you need to iterate over the list of elements. A good on-line resource for questions regarding scripting is StackOverflow (see e.g. https://stackoverflow.com/questions/18863187/how-can-i-loop-through...).

Best,

Clemens

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service