# Cross section optimization by iD's element in c#

**URL:** <https://discourse.mcneel.com/t/cross-section-optimization-by-ids-element-in-c/156316>\
**Category:** Karamba3D\
**Tags:** windows\
**Created:** [March 13, 2023, 2:59pm UTC](https://discourse.mcneel.com/t/cross-section-optimization-by-ids-element-in-c/156316 "2023-03-13T14:59:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Augustin\_L](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/augustin_l/32/414242_2.png) [@Augustin\_L](https://discourse.mcneel.com/u/Augustin_L)\
**Post date:** [March 13, 2023, 2:59pm UTC](https://discourse.mcneel.com/t/cross-section-optimization-by-ids-element-in-c/156316/1 "2023-03-13T14:59:59Z")

</div>

Hi everyone

I try to create a workflow to optimize wood cross section by the id of element. For that, I’m using the Karamba library in c#. I made a test but it looks like cross sections of the model are not updated during the optimization. Can someone help me with that ? I attached my grasshopper file and my csv cross section files to run the workflow.

Thanks

[CrossSecOptimization.gh](https://discourse.mcneel.com/uploads/short-url/gjoazz2rEqjIymM6B5JYkIZkzQM.gh) (66.6 KB)

[DataBaseForBeam.csv](https://discourse.mcneel.com/uploads/short-url/iM4uBbMloKRZzaxl3Luu36KcStw.csv) (24.5 KB)  
[DataBaseForColumn.csv](https://discourse.mcneel.com/uploads/short-url/rtNAqO28EdXZ01QVTvRXpyXHx7p.csv) (3.0 KB)

@karamba3d

---

<div class="post-metadata">

**Author:** ![cp1](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/cp1/32/472725_2.png) [@cp1](https://discourse.mcneel.com/u/cp1)\
**Post date:** [March 14, 2023, 10:16am UTC](https://discourse.mcneel.com/t/cross-section-optimization-by-ids-element-in-c/156316/2 "2023-03-14T10:16:42Z")

</div>

Hi @Augustin_L,

I cannot run your definition - the script throws an exception. What version and build of K3D do you use?

Try to debug the script using a cantilever with only one beam.

Does the scripting example work for you (see [here](https://scripting.karamba3d.com/2.-scripting/2.4-how-to-modify-structural-models/2.4.1-cross-section-optimization))?

– Clemens

---

<div class="post-metadata">

**Author:** ![Augustin\_L](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/augustin_l/32/414242_2.png) [@Augustin\_L](https://discourse.mcneel.com/u/Augustin_L)\
**Post date:** [March 14, 2023, 2:09pm UTC](https://discourse.mcneel.com/t/cross-section-optimization-by-ids-element-in-c/156316/3 "2023-03-14T14:09:20Z")

</div>

Hi Clemens,

I’m using the 2.2.0.17 version of karamba3D for rhino 7. For my side, the script doesn’t throw an exception. The script runs but there is a warning :“you may need to provide a runtime policy”. Here, I attached my cantilever beam example.

[DataBaseForBeam.csv](https://discourse.mcneel.com/uploads/short-url/iM4uBbMloKRZzaxl3Luu36KcStw.csv) (24.5 KB)

[cantilever\_beam.gh](https://discourse.mcneel.com/uploads/short-url/zO4WxLJLRm5GJJGavara4KtLJf4.gh) (47.9 KB)

---

<div class="post-metadata">

**Author:** ![karamba3d](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/karamba3d/32/472725_2.png) [@karamba3d](https://discourse.mcneel.com/u/karamba3d)\
**Post date:** [March 15, 2023, 1:48pm UTC](https://discourse.mcneel.com/t/cross-section-optimization-by-ids-element-in-c/156316/4 "2023-03-15T13:48:11Z")

</div>

Hi @Augustin_L,

I think you forgot to add the updated beam to the model:  
[cantilever\_beam\_cp.gh](https://discourse.mcneel.com/uploads/short-url/whQCP4lCd9uYwgxGNmeEhIxWUFZ.gh) (45.6 KB).

The warning is due to the fact that your version of RhinoCommon.dll is newer than that used for compiling Karamba3D. I haven’t found a good way yet to get rid of that message.

– Clemens
