# Create reinforcement with API \[SOLVED\]

**URL:** <https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258>\
**Category:** C#\
**Tags:** solved\
**Created:** [27 August 2024 11:04 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258 "2024-08-27T11:04:06Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![dfepe](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@dfepe](https://femdesign.discourse.group/u/dfepe)\
**Post date:** [27 August 2024 11:04 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/1 "2024-08-27T11:04:06Z")

</div>

Hi,

I saw in the API FemDesign.Core/Reinforcement/SurfaceReinforcement.cs that there are some functions to create surface reinforcement in Grasshopper and Dynamo. Is there an easy way to do it with C#?

I mean, it’s always possible to edit the xml file from C#, add new lines and create unique GUIDS somehow. But it is quite a complex process. The approach I normally follow is to create the basic reinforcement I want manually with the normal Fem Design user interface and then accessing the surface reinforcement in the following way:

```auto
slab[i].SurfaceReinforcement[i].Straight.Cover = 0.03;
slab[i].SurfaceReinforcement[i].Straight.Space = 0.10;

```

Then I can create a for loop to edit those parameters. Is there any “easy” way to add reinforcement using C# without editing the main model and saving it as .struxml?

---

<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:** [27 August 2024 12:59 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/2 "2024-08-27T12:59:54Z")

</div>

Hi @dfepe !

Theoretically, you can create a slab with reinforcement using c#.  
There are method which should help you in creating a slab with several type of reinforcement.

As you are familiar with Grasshopper, the way to add reinforcements to a slab is basically the same in c#.

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

The parameters like space and cover are stored inside the `FemDesign.Reinforcement.Straight` class.

The code to add reinforcement to a slab is shown in the following link.

> <https://github.com/strusoft/femdesign-api/blob/f93c787b85e461959642d849c451db696348bae5/FemDesign.Core/Reinforcement/SurfaceReinforcement.cs#L74>

Not sure if I have fully replied to your question. Are you trying to modify also an existing cover/space?

---

<div class="post-metadata">

**Author:** ![dfepe](https://avatars.discourse-cdn.com/v4/letter/d/b77776/32.png) [@dfepe](https://femdesign.discourse.group/u/dfepe)\
**Post date:** [27 August 2024 15:00 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/3 "2024-08-27T15:00:53Z")

</div>

Could you add an example? I don’t know how to define the list containing srfReinfs

---

<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:** [28 August 2024 10:16 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/4 "2024-08-28T10:16:57Z")

</div>

Hi @dfepe

I have created a minimal example that should help you in get started with the topic.

The program below is creating a slab with reinforcement on the x/y direction on the top and bottom face.

> <https://github.com/strusoft/femdesign-api/blob/8cbadbe3b00d14ec05f21cb0d48c0c723605335c/FemDesign.Examples/C%23/Example%208%20-%20SlabReinforcement/Program.cs>

Let me know if you need some more explaination.

---

<div class="post-metadata">

**Author:** ![AndreiM](https://dub1.discourse-cdn.com/flex017/user_avatar/femdesign.discourse.group/andreim/32/393_2.png) [@AndreiM](https://femdesign.discourse.group/u/AndreiM)\
**Post date:** [10 December 2024 18:01 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/5 "2024-12-10T18:01:37Z")

</div>

Hi Marco, I encounter an issue when trying to apply the reinforcement to a wall which includes a round hole:

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

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

Removing the hole allowes for the operation to be executed without any issues.

Do you have any idea if there is a way around 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:** [11 December 2024 09:49 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/6 "2024-12-11T09:49:30Z")

</div>

It seems that we do have a bug.

I have opened a GitHub issue and we will come back to you as soon as it is solved.

> <https://github.com/strusoft/femdesign-api/issues/1136>
>
> !\[immagine\](https://github.com/user-attachments/assets/311a6147-c284-4acb-b623-f…a9ac0f22f32)
> 
> 
> \## user request
> https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/5
> 
> \## file attached
> \[reinf-slab.zip\](https://github.com/user-attachments/files/18092900/reinf-slab.zip)

You can expect to have this feature solved in early January.

---

<div class="post-metadata">

**Author:** ![arturander](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@arturander](https://femdesign.discourse.group/u/arturander)\
**Post date:** [15 January 2025 20:29 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/7 "2025-01-15T20:29:23Z")

</div>

Maybe a stupid question but I’m already stuck in deconstructing the database variables. If I try to debug the code then it doesn’t have the location for filePath. I added a simple string and it reads in the locals but still gives an error.

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

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

---

<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:** [16 January 2025 08:06 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/9 "2025-01-16T08:06:40Z")

</div>

Ehi @arturander

Can you show the content of Materjald.struxml?

however, as you are reading your custom material database, I think you should write:

```auto
var materialDatabase = FemDesign.Materials.DeserializeStruxml(filePath);
var material = materialDatabase.MaterialByName("C25/30");

```

---

<div class="post-metadata">

**Author:** ![arturander](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@arturander](https://femdesign.discourse.group/u/arturander)\
**Post date:** [16 January 2025 08:21 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/10 "2025-01-16T08:21:34Z")

</div>

I just exported my default materials and I can read from the notepad that there are the concrete classes present.  
[Materjalid.struxml](https://femdesign.discourse.group/uploads/short-url/iMIKvnAd1qB5x79d5dyBejR1Zrz.struxml) (60.1 KB)

---

<div class="post-metadata">

**Author:** ![arturander](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@arturander](https://femdesign.discourse.group/u/arturander)\
**Post date:** [16 January 2025 08:24 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/11 "2025-01-16T08:24:55Z")

</div>

In the locals it reads but it doesn’t solve the deserialize problem. And debugging step by step I really can’t tell what is wrong at the moment. Last working line is 29, where it tries to return the concrete class parameters.

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

---

<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:** [16 January 2025 09:48 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/12 "2025-01-16T09:48:23Z")

</div>

It seems that you are using a .dll without any material/sections on it.

Have you downloaded the API from nuget?

> **[FemDesign.Core 23.9.0](https://www.nuget.org/packages/FemDesign.Core/)**
>
> The FEM-Design API package

Or you are referincing the .dll from a different location?  
If you are referencing the .dll locally, try to dowload the [femdesign\_csharp.zip](https://github.com/strusoft/femdesign-api/releases)

---

<div class="post-metadata">

**Author:** ![arturander](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@arturander](https://femdesign.discourse.group/u/arturander)\
**Post date:** [16 January 2025 10:05 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/13 "2025-01-16T10:05:36Z")

</div>

Yes, I have fiddled with the examples in the past about half or year ago. Updating nugget fixed the issue. Thanks! 🙂

---

<div class="post-metadata">

**Author:** ![arturander](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@arturander](https://femdesign.discourse.group/u/arturander)\
**Post date:** [16 January 2025 10:42 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/14 "2025-01-16T10:42:02Z")

</div>

One more comment. In the code the rebar cover is defined but in the calculation parameters it’s not. Is it possible in current API solution?  
And probably there would be more similar questions coming, is there a documentation file to look up for these possibilities of different methods?

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

---

<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:** [17 January 2025 09:08 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/15 "2025-01-17T09:08:17Z")

</div>

Ehi @arturander

It should be possible and I can help you with it.

In FEM-Design, we have access to most of the Calculation/Design parameters with a text file that can be loaded `programmatically`.

 ![image](https://europe1.discourse-cdn.com/flex017/uploads/femdesign_api/original/1X/73f4e86a0527f4990d5a9526705cb4ea255c6fff.jpeg)

The starting point will be to dump an existing `settings file` which can be modified to better suite your needs.  
Have a look at the explanation in the following  
[documentation page](https://femdesign-api-docs.onstrusoft.com/docs/advanced/fdscript#calculationdesign-configurations)

Loading the cfg.xml file will only require a simple:

```auto
femdesign.SetConfig(filePath)

```

> <https://github.com/strusoft/femdesign-api/blob/9dbe793bcc9963f5ee988ad7bdb421e3543ce3a0/FemDesign.Core/FemDesignConnection.cs#L290-L299>

---

<div class="post-metadata">

**Author:** ![arturander](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@arturander](https://femdesign.discourse.group/u/arturander)\
**Post date:** [23 April 2025 13:41 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/16 "2025-04-23T13:41:42Z")

</div>

Trying to create a script where I can take an existing model and reinforce a slab there. But I’m missing something. If I jump over the code and look at the locals then it retrieves my slab but for some reason doesn’t update the model in any way.  
Uploaded main code.  
[Program2.cs](https://femdesign.discourse.group/uploads/short-url/xy0IC18LOnUqEVnsTYneVLGnUQj.cs) (3.7 KB)

---

<div class="post-metadata">

**Author:** ![anLor](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@anLor](https://femdesign.discourse.group/u/anLor)\
**Post date:** [9 May 2025 18:28 UTC](https://femdesign.discourse.group/t/create-reinforcement-with-api-solved/258/17 "2025-05-09T18:28:27Z")

</div>

Hi @arturander! 👋

Try using the `Model.AddElements()` method to add your ‘reinforcedSlab’ to the ‘model’. I’ve also attached the modified file. It worked for me. Let me know if you need further help.

[Program2\_mod.cs](https://femdesign.discourse.group/uploads/short-url/9b0sNLbujalZWvWMEsYppvXDcsB.cs) (3.8 KB)
