Show last authors
1 (% class="box floatinginfobox" %)
2 (((
3 [[FEM-Design API examples on GitHub>>https://github.com/strusoft/femdesign-api-example]]
4
5
6 Contents
7
8 {{toc depth="3"/}}
9 )))
10
11 More in this chapter:
12
13 * [[Getting started>>doc:FEM-Design API.Getting started.WebHome]]
14 * [[Run script>>doc:Invitation.WebHome]]
15 * [[API wrapper>>doc:FEM-Design API.API wrapper.WebHome]]
16 * [[Dynamo API>>doc:FEM-Design API.Dynamo API.WebHome]]
17
18 ----
19
20
21 = Save existing model as struxml =
22
23
24 (% style="text-align: justify;" %)
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.
26
27
28 [[image:1556898277772-731.png||height="383" width="800"]]
29
30
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 ++.
32
33
34
35 = Example 1 - Pile stiffness =
36
37
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]]
39
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
42
43 {{video height="100" ratio="16:9" url="https://youtu.be/J6JJofgDT7Q" width="100"/}}
44
45
46
47 To better understand the final code, please see the picture below.
48
49
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"]]
59
60 (((
61 (% class="box successmessage" %)
62 (((
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 )))
65 )))
66
67
68 [[image:1557159371286-480.png||height="318" width="600"]][[image:1557159404913-728.png||height="148" width="600"]]
69
70
71
72
73
74 = Example 2 - Parametric wall =
75
76
77
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]]
79
80 (% style="text-align: justify;" %)
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:
82
83
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]
92
93 [[image:1557146467475-391.png||height="474" width="800"]]
94
95
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.
97
98
99 (((
100 (% class="box successmessage" %)
101 (((
102 NOTE: Place the python script and the model file in the same directory to get the code to run.
103 )))
104 )))
105
106 ----
107
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 2019 StruSoft AB
FEM-Design Wiki