Hide last authors
Iwona Budny Bjergø 26.1 1 (% class="box floatinginfobox" %)
2 (((
Isak Björhag 57.1 3 [[FEM-Design API examples on GitHub>>https://github.com/strusoft/femdesign-api-example]]
IwonaBudny 14.1 4
Isak Björhag 57.1 5
Iwona Budny Bjergø 60.1 6 Contents
Isak Björhag 57.1 7
Iwona Budny Bjergø 33.1 8 {{toc depth="3"/}}
Iwona Budny Bjergø 26.1 9 )))
IwonaBudny 14.1 10
Iwona Budny Bjergø 60.1 11 More in this chapter:
IwonaBudny 14.1 12
IwonaBudny 15.1 13 * [[Getting started>>doc:FEM-Design API.Getting started.WebHome]]
IwonaBudny 14.1 14 * [[Run script>>doc:Invitation.WebHome]]
IwonaBudny 15.1 15 * [[API wrapper>>doc:FEM-Design API.API wrapper.WebHome]]
Iwona Budny Bjergø 64.1 16 * [[Dynamo API>>doc:FEM-Design API.Dynamo API.WebHome]]
IwonaBudny 14.1 17
18 ----
19
20
Iwona Budny Bjergø 33.1 21 = Save existing model as struxml =
IwonaBudny 3.1 22
Iwona Budny Bjergø 33.1 23
24 (% style="text-align: justify;" %)
Isak Björhag 11.1 25 In most situations where a script or some kind of automation is needed it is easiest to modify an existing XML file. This can be done in many different ways and in many different programming languages. Start out by modelling the structure in FEM-Design as usual. Then save the model file as a XML-file. The model file can be saved as struxml file by going to "File/Save as..." and choosing struxml as the file type.
IwonaBudny 3.1 26
Iwona Budny Bjergø 33.1 27
Isak Björhag 63.1 28 [[image:1556898277772-731.png||height="383" width="800"]]
IwonaBudny 5.1 29
Isak Björhag 11.1 30
Isak Björhag 55.1 31 You can open and view the xml-file in a text editor to quickly identify what attribute or text that you want to modify. We recommend XML Notepad or Notepad ++.
Isak Björhag 11.1 32
Iwona Budny Bjergø 58.1 33
34
Iwona Budny Bjergø 33.1 35 = Example 1 - Pile stiffness =
Isak Björhag 27.1 36
Iwona Budny Bjergø 33.1 37
Isak Björhag 63.1 38 |=(% style="background-color: rgb(29, 89, 152); width: 261px;" %)(% style="color:#ffffff" %)Example 1 - Pile stiffness|=(% style="width: 1216px;" %)[[⭳ Download example 1>>https://drive.google.com/a/strusoft.com/uc?authuser=0&id=1yPetucu-ApTPE7ubRNmmkG3VGv52hL6x&export=download]]
Iwona Budny Bjergø 33.1 39
Isak Björhag 11.1 40 The current example will illustrate how to modify an existing XML file to adjust the stiffness of a point support with regard to the reaction in the support. This will illustrate how to make changes to the model, run the analysis and then make additional changes depending on the result. This is a very common situation and the main work flow can be used in many different situations, for example optimization.
41
Iwona Budny Bjergø 33.1 42
Isak Björhag 65.1 43 {{video url="https://youtu.be/J6JJofgDT7Q" width="50%"/}}
Isak Björhag 10.1 44
Iwona Budny Bjergø 33.1 45
Iwona Budny Bjergø 36.1 46
Isak Björhag 11.1 47 To better understand the final code, please see the picture below.
Isak Björhag 10.1 48
Iwona Budny Bjergø 33.1 49
Isak Björhag 63.1 50 |(% style="width:351px" %)Import|(% style="width:1126px" %)[[image:1560771158116-573.png||height="90" width="302"]]
51 |(% style="width:351px" %)Input|(% style="width:1126px" %)[[image:1560771182141-325.png||height="144" width="534"]]
52 |(% style="width:351px" %)Identify and save original gamma factors|(% style="width:1126px" %)[[image:1560771228867-938.png||height="181" width="579"]]
53 |(% style="width:351px" %)Read model file|(% style="width:1126px" %)[[image:1560771289380-245.png||height="82" width="604"]]
54 |(% style="width:351px" %)Write new gamma factors with regard to load step|(% style="width:1126px" %)[[image:1560771347907-586.png||height="124" width="641"]]
55 |(% style="width:351px" %)Run analysis|(% style="width:1126px" %)[[image:1560771478731-491.png||height="88" width="544"]]
56 |(% style="width:351px" %)Read model file|(% style="width:1126px" %)[[image:1560771542309-517.png||height="38" width="450"]]
57 |(% style="width:351px" %)Read reactions|(% style="width:1126px" %)[[image:1560771684392-495.png||height="123" width="523"]]
58 |(% style="width:351px" %)Write new support stiffness|(% style="width:1126px" %)[[image:1560771755994-352.png||height="379" width="766"]]
Isak Björhag 10.1 59
Iwona Budny Bjergø 33.1 60 (((
Iwona Budny Bjergø 52.1 61 (% class="box successmessage" %)
62 (((
Iwona Budny Bjergø 33.1 63 NOTE: To get the script to work you have to check the file path inside the python code and also in the script-file.
64 )))
Iwona Budny Bjergø 52.1 65 )))
Iwona Budny Bjergø 33.1 66
67
Isak Björhag 63.1 68 [[image:1557159371286-480.png||height="318" width="600"]][[image:1557159404913-728.png||height="148" width="600"]]
Isak Björhag 19.2 69
Iwona Budny Bjergø 51.1 70
71
72
Iwona Budny Bjergø 59.1 73
Iwona Budny Bjergø 35.1 74 = Example 2 - Parametric wall =
Iwona Budny Bjergø 33.1 75
76
Iwona Budny Bjergø 53.1 77
Isak Björhag 63.1 78 |=(% style="background-color: rgb(29, 89, 152); width: 261px;" %)(% style="color:#ffffff" %)Example 2 - Parametric wall|=(% style="width: 1216px;" %)[[⭳ Download example 2>>https://drive.google.com/a/strusoft.com/uc?authuser=0&id=10p_F-EIV8WRdKOkpzwYjVVG8RIB4AzLO&export=download]]
Iwona Budny Bjergø 33.1 79
80 (% style="text-align: justify;" %)
Isak Björhag 16.2 81 This example will illustrate how to create a parametric wall. The goal is to be able to adjust different measurements of an existing wall to make modelling more efficient and minimize errors. The example is a prefabricated wall and the measurements that should be parametric are:
Isak Björhag 12.2 82
83
Iwona Budny Bjergø 54.1 84 |(% style="width:263px" %)(% style="color:null" %)**Parameters**|(% style="width:1214px" %)
85 |(% style="width:263px" %)(% style="color:null" %)##wallHeight##|(% style="width:1214px" %)The total height of the wall [m]
86 |(% style="width:263px" %)(% style="color:null" %)##wallLength##|(% style="width:1214px" %)The total length of the wall [m]
87 |(% style="width:263px" %)(% style="color:null" %)##windowX##|(% style="width:1214px" %)The x-position of the window [m]
88 |(% style="width:263px" %)(% style="color:null" %)##windowY##|(% style="width:1214px" %)The y-position of the window [m]
89 |(% style="width:263px" %)(% style="color:null" %)##windowW##|(% style="width:1214px" %)The window width [m]
90 |(% style="width:263px" %)(% style="color:null" %)##doorPos##|(% style="width:1214px" %)The position of the door [m]
91 |(% style="width:263px" %)(% style="color:null" %)##connectionCapacity##|(% style="width:1214px" %)The connection capacity for each of the point connections [kN]
Iwona Budny Bjergø 33.1 92
Isak Björhag 63.1 93 [[image:1557146467475-391.png||height="474" width="800"]]
Isak Björhag 16.2 94
95
Iwona Budny Bjergø 33.1 96 The code will use an existing wall model saved as struxml and change different parameters with regard to the defined parameters. This file is included in the example. It is recommended to have some kind of input check so that the input values are possible to model, for example ##doorPos+1 < wallLength##. This is however not included in the example.
Isak Björhag 23.2 97
Iwona Budny Bjergø 37.1 98
Iwona Budny Bjergø 33.1 99 (((
Iwona Budny Bjergø 52.1 100 (% class="box successmessage" %)
101 (((
Iwona Budny Bjergø 33.1 102 NOTE: Place the python script and the model file in the same directory to get the code to run.
103 )))
Iwona Budny Bjergø 52.1 104 )))
Iwona Budny Bjergø 61.1 105
106 ----
107
Iwona Budny Bjergø 62.1 108 (% style="text-align: justify;" %)
109 (% class="small" %)Disclaimer: All example files, wrappers and documentation are for illustrative and educational purposes and may not interact with FEM-Design in a reliable way depending on your version, installation and content of the files. Furthermore, StruSoft won´t guarantee full support of the API functions since they are customizable by the customer.
Copyright 2020 StruSoft AB
FEM-Design Wiki