# Using FdScript to set calculation/design parameters to an element with guid \[SOLVED\]

**URL:** <https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464>\
**Category:** C#\
**Created:** [5 February 2025 20:01 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464 "2025-02-05T20:01:51Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![KPN](https://dub1.discourse-cdn.com/flex017/user_avatar/femdesign.discourse.group/kpn/32/379_2.png) [@KPN](https://femdesign.discourse.group/u/KPN)\
**Post date:** [5 February 2025 20:01 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/1 "2025-02-05T20:01:51Z")

</div>

Hello,  
I would like to ask if I understand FdScript correct.  
Marco said this could be used to set parameters that is not available in API se post:  
[Discussion on FdScript](https://femdesign.discourse.group/t/design-of-concrete-structure-retaining-wall-using-load-groups-solved/404/6)

If I would like to change crack width a Fdscript, it would look something like this?

> \<‘cmdconfig command=“$ MODULECOM APPLYCFG”\>  
> \<’!-- EUROCODE CALCULATION PARAMETERS CONCRETE SHELL →   
> \<'CONFIG face\_0\_rCwLimit=“0.2” face\_1\_rCwLimit=“0.2”\>  
> \<‘GUID\>2e290437-e86a-4e36-af7d-acde6a6146c8  
> \<’/CONFIG\>  
> \<‘CONFIG face\_0\_rCwLimit=“0.3” face\_1\_rCwLimit=“0.3”\>  
> \<‘GUID\>2cba9c00-255d-4258-94fb-f164aafff214  
> \<’/CONFIG\>  
> \<’/cmdconfig\>

That would be run in c# like this?

> FemDesignConnection.SetConfig(string filepath)

I interpret that as the analysed structure needs to be static.  
Having the API creating the object will cause a new randomly generated guid every time API is run, causing guid given in the Fdstript to be “out of date”?

---

<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:** [6 February 2025 11:46 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/2 "2025-02-06T11:46:09Z")

</div>

ehi @KPN !

Depending on your case study, you can do something like the following to statically set the `Guid` of an object.  
As a note, Fdscript Guid always refer to the analytical Guid which is the one on the attribute.

```auto
slab.Guid = new Guid( "{F42D2623-FB17-4F39-9A21-EDDA24944298}");
slab.SlabPart.Guid = new Guid("{A951B736-3394-4FE4-B38F-D17F1161EB3A}");

```

If needed, we can implement the features so that you can use it by C#.  
In that way, you can avoid in creating the text file manually.

---

<div class="post-metadata">

**Author:** ![KPN](https://dub1.discourse-cdn.com/flex017/user_avatar/femdesign.discourse.group/kpn/32/379_2.png) [@KPN](https://femdesign.discourse.group/u/KPN)\
**Post date:** [7 February 2025 16:10 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/3 "2025-02-07T16:10:17Z")

</div>

Sorry in advance for long post 😅  
I have done an honest attempt even if I find quite a lot of work learning a different coding concept with separate files just to do a thing, I think is quite essential for concrete construction.

In element creation:

> // Set static Guid  
> SlabBPL.SlabPart.Guid = new Guid(“A951B736-3394-4FE4-B38F-D17F1161EB3A”);  
> SlabMUR.SlabPart.Guid = new Guid(“F42D2623-FB17-4F39-9A21-EDDA24944298”);  
> SlabBPLMUR.SlabPart.Guid = new Guid(“2E290437-E86A-4E36-AF7D-ACDE6A6146C8”);

FdScript:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<fdscript xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="fdscript.xsd">
  <!-- SCRIPT HEADER ================================================================================== -->
  <fdscriptheader>
    <title>FEM-Design Test script</title>
    <version>2300</version>
    <module>SFRAME</module>
    <!-- log file where warnings from calculation and other interesting entries may appear -->
    <logfile>C:\Users\kpn\VS local\FemDesign.KPN\RetainingWall\Test.log</logfile>
  </fdscriptheader>

	<!-- SCRIPT	CONFIGURATIONS ================================================================================== -->
  <cmdconfig command="$ MODULECOM APPLYCFG">
  	<!-- EUROCODE CALCULATION PARAMETERS CONCRETE SHELL -->
  	<!-- Face_0 = UK	Face_1 = OK -->
  	<!-- BPL -->
  	<configs>
  		<CONFIG face_0_rCwLimit="0.25" face_1_rCwLimit="0.30">
			<GUID>A951B736-3394-4FE4-B38F-D17F1161EB3A</GUID> 
  		</CONFIG>
  		<!-- MUR -->
		<CONFIG face_0_rCwLimit="0.35" face_1_rCwLimit="0.40">
  			<GUID>F42D2623-FB17-4F39-9A21-EDDA24944298</GUID>
  		</CONFIG>
		<!-- BPLMUR -->
		<CONFIG face_0_rCwLimit="0.45" face_1_rCwLimit="0.50">
			<GUID>2E290437-E86A-4E36-AF7D-ACDE6A6146C8</GUID>
		</CONFIG>
	</configs>
  </cmdconfig>

  <!-- END SESSION =================================================================================== -->
</fdscript>

```

Exported config file:  
[cfg.xml](https://femdesign.discourse.group/uploads/short-url/u4Y1qxwgIh3dks3QXkZW8stQN8P.xml) (25.4 KB)  
.Struxml file:  
[Retainingwall.struxml](https://femdesign.discourse.group/uploads/short-url/zkwyCDMBiAru5fGnrVo7ECJUySI.struxml) (108.2 KB)

When testing I used Fem-Design Console Tab `Tools -> Run script`

Error massage in log:

> step: cmdconfig  
> t: 02/07 15.44.10.354  
> cmdconfig:‘$ MODULECOM APPLYCFG’  
> element expected  
> t: 02/07 15.44.10.355  
> aborting script execution  
> Script file finished

Have you any clue what can be wrong with my FdScript?

Sidenote: In bridge construction exposure class is important as surfaces often is subjected to water or chlorides. Example in road environment leading to affecting reinforcement needed for design. I asked my colleague that works designing buildings and according to him crack width is also relevant for him when designing foundation and other concrete surfaces that can be subjected to water/chlorides (even if the corrosive environments are more important in bridge design).

In conclusion, cracks are important for most reinforcement design and can affect utilization rate. Therefore, my opinion is that crack width should be easy to control within the API.  
Feels like it relates to this old post about setting “design parameters”.  
Maybe setting crack width can be implement at the same time? 😊

[Workflow to design a retaining wall through the API #1116](https://github.com/strusoft/femdesign-api/issues/1116)

---

<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:** [10 February 2025 12:00 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/4 "2025-02-10T12:00:42Z")

</div>

> [@KPN](#):
>
> conclusion, cracks are important for most reinforcement design and can affect utilization rate. Therefore, my opinion is that crack width should be easy to control within the API

Ehi @KPN

Thanks a lot for the explanation.

The API has some “holes” in the design/calculation settings and it seems that we should improve some aspect 🙂

I will try to squeeze in some development so that you can programmatically create the fdscript by C#.

However, I have done some little test and it seems to work on my side.

**NOTE**

- You need to have matched `GUID` in the .struxml and .fdscript (slabpart)

- Use the type attribute (i.e. `type="ECCALCPARAMSHELLRC"`)

- You can omit some attribute if you do not want to set a new value

- Remember to open the file through .fdscript using cmdopen

Let me know if it is working for you 🙂

[setCalculationParameters.zip](https://femdesign.discourse.group/uploads/short-url/pkIvsejo9gwY8gAXeFoPpL89Yf7.zip) (9.9 KB)

---

<div class="post-metadata">

**Author:** ![KPN](https://dub1.discourse-cdn.com/flex017/user_avatar/femdesign.discourse.group/kpn/32/379_2.png) [@KPN](https://femdesign.discourse.group/u/KPN)\
**Post date:** [10 February 2025 16:31 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/5 "2025-02-10T16:31:35Z")

</div>

Thanks for your help!  
Now the .FdScript work if I run it with `Tools -> Run script` 🙂  
[SetCrackwidth.zip](https://femdesign.discourse.group/uploads/short-url/23IXPvJgbkUAbd8rmcD22X5CEsz.zip) (947 Bytes)  
But when the script is run though the API with `FemDesignConnection.SetConfig(string filepath)` I get the following error message (with a bunch of other message of successful script runs “Script file finished”):

> cmdconfig:‘$ MODULECOM APPLYCFG’  
> \<'CONFIG\> element expected  
> t: 02/10 17.03.11.914  
> aborting script execution

Hmm I find `SetConfig.fdscript` in folder `C:\Users\kpn\VS local\FemDesign.KPN\RetainingWall\scripts` with code:

```auto
<?xml version="1.0" encoding="utf-8"?>
<fdscript xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <fdscriptheader>
    <title>FEM-Design script</title>
    <version>2300</version>
    <module>SFRAME</module>
    <logfile>C:\Users\kpn\VS local\FemDesign.KPN\RetainingWall\logfile.log</logfile>
  </fdscriptheader>
  <cmdconfig command="$ MODULECOM APPLYCFG" file="C:\Users\kpn\VS local\FemDesign.KPN\RetainingWall\SetCrackwidth.Fdscript" />
</fdscript>

```

For me it looks like it should work the same as running the file manually.  
How did you run your .FdScript from the API?

---

<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:** [10 February 2025 17:11 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/6 "2025-02-10T17:11:46Z")

</div>

```xml
<?xml version="1.0" encoding="UTF-8"?>
<configs>
	<CONFIG face_0_rCwLimit="0.25" face_1_rCwLimit="0.15" type="ECCALCPARAMSHELLRC">
			<GUID>dadc75a8-1d7f-4b64-9334-2f84c4c0791f</GUID>
    </CONFIG>
    <CONFIG face_0_rCwLimit="0.50" face_1_rCwLimit="0.80" type="ECCALCPARAMSHELLRC">
        <GUID>65d12119-eb0c-48a0-b4bf-f50827031b52</GUID>
    </CONFIG>
</configs>

```

is your `cfg.xml` file looking like this?

it should only be a series of `CONFIG` within a `configs` xmlelement.  
It works on my side

---

<div class="post-metadata">

**Author:** ![KPN](https://dub1.discourse-cdn.com/flex017/user_avatar/femdesign.discourse.group/kpn/32/379_2.png) [@KPN](https://femdesign.discourse.group/u/KPN)\
**Post date:** [11 February 2025 11:51 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/7 "2025-02-11T11:51:19Z")

</div>

Have edit cfg.xml in the project folder so it matches the .FdScript  
`C:\Users\kpn\VS local\FemDesign.KPN\RetainingWall`  
Is this the correct? I also see that there is a cfg.xml in:  
`C:\Users\kpn\VS local\FemDesign.Core\Calculate\Config`

```auto
<?xml version="1.0" encoding="UTF-8"?>
<configs>
	<!-- Face_0 = UK	Face_1 = ÖK -->
	<!-- BPL -->
		<CONFIG face_0_rCwLimit="0.25" face_1_rCwLimit="0.30" type="ECCALCPARAMSHELLRC">
			<GUID>A951B736-3394-4FE4-B38F-D17F1161EB3A</GUID>
		</CONFIG>
		<!-- MUR -->
		<CONFIG face_0_rCwLimit="0.35" face_1_rCwLimit="0.40" type="ECCALCPARAMSHELLRC">
			<GUID>F42D2623-FB17-4F39-9A21-EDDA24944298</GUID>
		</CONFIG>
		<!-- BPLMUR -->
		<CONFIG face_0_rCwLimit="0.45" face_1_rCwLimit="0.50" type="ECCALCPARAMSHELLRC">
			<GUID>2E290437-E86A-4E36-AF7D-ACDE6A6146C8</GUID>
		</CONFIG>
</configs>

```

Is this run? I still get the same error message.

---

<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:** [12 February 2025 08:42 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/9 "2025-02-12T08:42:15Z")

</div>

For anyone interested in the issue.

The user was calling SetConfig(filePath) where filePath was actually an fdscript file.

Below, the correct way to set calculation/design parameters using the CONFIG

```auto
// Set crack width
var configFilePath= "cfg.xml";
ReinforcementDesignFEM.SetConfig(configFilePath);

```

where `cfg.xml`

```auto
<?xml version="1.0" encoding="UTF-8"?>
<configs>
	<!-- Face_0 = UK	Face_1 = ÖK -->
	<!-- BPL -->
		<CONFIG face_0_rCwLimit="0.25" face_1_rCwLimit="0.30" type="ECCALCPARAMSHELLRC">
			<GUID>A951B736-3394-4FE4-B38F-D17F1161EB3A</GUID>
		</CONFIG>
		<!-- MUR -->
		<CONFIG face_0_rCwLimit="0.35" face_1_rCwLimit="0.40" type="ECCALCPARAMSHELLRC">
			<GUID>F42D2623-FB17-4F39-9A21-EDDA24944298</GUID>
		</CONFIG>
		<!-- BPLMUR -->
		<CONFIG face_0_rCwLimit="0.45" face_1_rCwLimit="0.50" type="ECCALCPARAMSHELLRC">
			<GUID>2E290437-E86A-4E36-AF7D-ACDE6A6146C8</GUID>
		</CONFIG>
</configs>

```

---

<div class="post-metadata">

**Author:** ![KPN](https://dub1.discourse-cdn.com/flex017/user_avatar/femdesign.discourse.group/kpn/32/379_2.png) [@KPN](https://femdesign.discourse.group/u/KPN)\
**Post date:** [12 February 2025 09:16 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/10 "2025-02-12T09:16:53Z")

</div>

Thank for all your help Marco!  
I will try to summary what I learned.  
Maybe it will help someone else 🙂  
If I would do some other configuration setting with API I would follow this steps:

1. Set the desired configurations and use the following command in Fem-Design

> ; CXL MODULECOM WXMLCFG:C:\temp\cfg.xml

Alternatively start with the cfg.xml described in link: [FdScript | FEM-Design API](https://femdesign-api-docs.onstrusoft.com/docs/advanced/fdscript)

1. Edit the cfg.xml file so it only includes configurations I want to change. Example of structure:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<configs>
	<!-- Face_0 = UK	Face_1 = ÖK -->
	<!-- BPL -->
		<CONFIG face_0_rCwLimit="0.25" face_1_rCwLimit="0.30" type="ECCALCPARAMSHELLRC">
			<GUID>A951B736-3394-4FE4-B38F-D17F1161EB3A</GUID>
		</CONFIG>
		<!-- MUR -->
		<CONFIG face_0_rCwLimit="0.35" face_1_rCwLimit="0.40" type="ECCALCPARAMSHELLRC">
			<GUID>F42D2623-FB17-4F39-9A21-EDDA24944298</GUID>
		</CONFIG>
		<!-- BPLMUR -->
		<CONFIG face_0_rCwLimit="0.45" face_1_rCwLimit="0.50" type="ECCALCPARAMSHELLRC">
			<GUID>2E290437-E86A-4E36-AF7D-ACDE6A6146C8</GUID>
		</CONFIG>
</configs>

```

- All configs needs a type.
- Part specific configs needs a guid
- Guid of slabs can be extracted with `Slab.Slabpart.Guid` or can be seen in the .Struxml file.
- Comments can be given with `<!-- XXX -->`

1. Implement the configuration in API with:

> String filepath = “cfg.xml”;  
> FemDesignConnection.SetConfig(string filepath)

Maybe a cofig setting could be listed under FemDesign.Examples?  
Or maybe this post is enough.

---

<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:** [12 February 2025 09:36 UTC](https://femdesign.discourse.group/t/using-fdscript-to-set-calculation-design-parameters-to-an-element-with-guid-solved/464/11 "2025-02-12T09:36:35Z")

</div>

Let’s go for a C# example in our repository 🙂

Thanks for your feedbacks.

> <https://github.com/strusoft/femdesign-api/issues/1147>

FYI:  
We will implement those ConfigSettings so that you can avoid using the xml file.  
We want our users to be able to do something like:

```auto
new calcShellRc = new CALCPARAMSHELLRC( foo, foo1, foo2 );
new calcShellRc = new CALCPARAMSHELLRC( foo, foo1, foo2 );
var config = new Config(calcShellRc );

connetion.Setconfig(config);

```

I will keep you update when this is possible!
