# Bar reinforcement in C# \[SOLVED\]

**URL:** <https://femdesign.discourse.group/t/bar-reinforcement-in-c-solved/557>\
**Category:** C#\
**Tags:** solved\
**Created:** [7 October 2025 10:41 UTC](https://femdesign.discourse.group/t/bar-reinforcement-in-c-solved/557 "2025-10-07T10:41:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jona995k](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Jona995k](https://femdesign.discourse.group/u/Jona995k)\
**Post date:** [7 October 2025 10:41 UTC](https://femdesign.discourse.group/t/bar-reinforcement-in-c-solved/557/1 "2025-10-07T10:41:49Z")

</div>

hello. i am trying to create a script that takes a existing model and applies some amount (the same for all beams) of longitutional and stirrup reinforcement to all beams in the model.

I wonder how this could be done in C# since the reinforcement is drawn by hand in FEM:

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/femdesign_api/original/1X/12c26b135a7d400a4d0f716cc3e703251c70c05b.png)

something like this?

---

<div class="post-metadata">

**Author:** ![MarcoPelle](https://dub1.discourse-cdn.com/flex017/user_avatar/femdesign.discourse.group/marcopelle/32/6_2.png) [@MarcoPelle](https://femdesign.discourse.group/u/MarcoPelle)\
**Post date:** [8 October 2025 08:44 UTC](https://femdesign.discourse.group/t/bar-reinforcement-in-c-solved/557/2 "2025-10-08T08:44:30Z")

</div>

Hi @Jona995k !

Have a look at the following example related to Slab. It might give you some idea.

> <https://github.com/ms-structural/femdesign-api/blob/master/FemDesign.Examples/C%23/Example%208%20-%20SlabReinforcement/Program.cs>

I need to create one for Bar as well as it is not super easy to navigate through the object classes for reinforcement.

Below, you can see the documentation for Beam.

> **[Class Bar | FemDesign.Core 24.2.0 | DNDocs](https://docs.dndocs.com/n/FemDesign.Core/24.2.0/api/FemDesign.Bars.Bar.html#FemDesign_Bars_Bar_Reinforcement)**
>
> bar\_type Bar-element

---

<div class="post-metadata">

**Author:** ![Jona995k](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Jona995k](https://femdesign.discourse.group/u/Jona995k)\
**Post date:** [9 October 2025 06:01 UTC](https://femdesign.discourse.group/t/bar-reinforcement-in-c-solved/557/3 "2025-10-09T06:01:21Z")

</div>

```csharp
// EDIT BEAM
var reinforcement = FemDesign.Materials.MaterialDatabase.GetDefault().MaterialByName("B500B");

var diameter_16 = 0.016;
var cover = 0.025;
double st = 0;
double end = 2;
var point = new FemDesign.Geometry.Point2d(0,0);
var anchorLength = 0.8;
           

var wire = new Wire(diameter_16, reinforcement, WireProfileType.Ribbed);

var elements = new List<FemDesign.GenericClasses.IStructureElement> {};

// Loop through all bars in the model and add longitudinal reinforcement
for (int i = 0; i < model.Entities.Bars.Count; i++)
{
    var beam = model.Entities.Bars[i];
    var longbar = new LongitudinalBar(beam, point, anchorLength, anchorLength, st, end, false);

    var arm_top = new LongitudinalBarReinforcement(beam, wire, longbar);
    var arm_list = new List<BarReinforcement> { arm_top };

    var reinfbar = FemDesign.Reinforcement.LongitudinalBarReinforcement.AddReinforcementToBar(beam, arm_list, true);
    elements.Add(reinfbar);
}

var model1 = new Model(Country.DK, elements);

using (var connection = new FemDesignConnection(keepOpen: true))
{
    connection.Open(model);
}

```

from your answer i wrote this. but the reinforcement is not transfered to the new model. is there an obvious reason why? 🙂

---

<div class="post-metadata">

**Author:** ![Jona995k](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Jona995k](https://femdesign.discourse.group/u/Jona995k)\
**Post date:** [10 October 2025 05:21 UTC](https://femdesign.discourse.group/t/bar-reinforcement-in-c-solved/557/4 "2025-10-10T05:21:27Z")

</div>

nevermind i solved it! 🙂

---

<div class="post-metadata">

**Author:** ![MarcoPelle](https://dub1.discourse-cdn.com/flex017/user_avatar/femdesign.discourse.group/marcopelle/32/6_2.png) [@MarcoPelle](https://femdesign.discourse.group/u/MarcoPelle)\
**Post date:** [20 October 2025 16:59 UTC](https://femdesign.discourse.group/t/bar-reinforcement-in-c-solved/557/5 "2025-10-20T16:59:20Z")

</div>

Great! Do you mind in showing where the mistake was ? It will help other users 🙂

---

<div class="post-metadata">

**Author:** ![Jona995k](https://avatars.discourse-cdn.com/v4/letter/j/d2c977/32.png) [@Jona995k](https://femdesign.discourse.group/u/Jona995k)\
**Post date:** [21 October 2025 04:22 UTC](https://femdesign.discourse.group/t/bar-reinforcement-in-c-solved/557/6 "2025-10-21T04:22:48Z")

</div>

```auto
// script works. simple mistake. just needed to declare variables correctly

var model = new Model(Country.DK, elements);

using (var connection = new FemDesignConnection(keepOpen: true))
{
    connection.Open(model);
}

```
