Hide last authors
IwonaBudny 20.1 1 (% class="box floatinginfobox" %)
2 (((
Isak Björhag 50.1 3 [[FEM-Design API examples on GitHub>>https://github.com/strusoft/femdesign-api-example]]
4
Isak Björhag 70.1 5 [[API-wrapper as zip>>https://drive.google.com/a/strusoft.com/uc?authuser=0&id=1_YOWErsPWaIy8dFUIx1yMJlTLQhhH1x8&export=download]]
Isak Björhag 43.1 6
IwonaBudny 18.1 7
Iwona Budny Bjergø 61.1 8 Contents
Isak Björhag 24.1 9
Isak Björhag 63.1 10 (% contenteditable="false" tabindex="-1" %)
Isak Björhag 40.1 11 (((
Isak Björhag 41.1 12 {{toc depth="4"/}}
IwonaBudny 21.1 13 )))
Isak Björhag 40.1 14 )))
IwonaBudny 18.1 15
Iwona Budny Bjergø 61.1 16 More in this chapter:
IwonaBudny 19.1 17
IwonaBudny 25.1 18 * [[Getting started>>doc:FEM-Design API.Getting started.WebHome]]
IwonaBudny 19.1 19 * [[Run Script>>doc:FEM-Design API.Run script.WebHome]]
IwonaBudny 26.1 20 * [[Modifying an XML file using Python>>doc:FEM-Design API.Optimization using Python script.WebHome]]
Iwona Budny Bjergø 68.1 21 * [[Dynamo API>>doc:FEM-Design API.Dynamo API.WebHome]]
IwonaBudny 19.1 22
IwonaBudny 21.1 23 ----
24
Iwona Budny Bjergø 42.1 25 (% style="text-align: justify;" %)
Isak Björhag 49.1 26 An API wrapper is a file containing different call functions to make it easier to create the model and run the analysis. The wrapper below is created for python. Please see a detailed description in the documentation below.
Isak Björhag 7.2 27
Isak Björhag 48.1 28
Isak Björhag 63.1 29 (% class="box warningmessage" style="text-align: justify;" %)
Isak Björhag 47.1 30 (((
Iwona Budny Bjergø 60.1 31 Note: This is just an example of a wrapper. You are of course able to create a wrapper file yourself or make changes in the wrapper to fit your project or situation with regard to input values and different call functions. For further information about this, please visit the section [[__**Customize the wrapper.**__>>doc:||anchor="Customize_wrapper"]]
Isak Björhag 47.1 32 )))
Iwona Budny Bjergø 42.1 33
Isak Björhag 47.1 34
Isak Björhag 16.1 35 = API-wrapper for python =
36
Iwona Budny Bjergø 42.1 37
Isak Björhag 16.1 38 The following information is valid for python. However, it is possible to construct a similar wrapper for other programming languages.
39
Iwona Budny Bjergø 42.1 40
Isak Björhag 41.1 41 {{video ratio="16:9" url="https://youtu.be/tC5mxDIf7aE"/}}
42
Isak Björhag 63.1 43 (% contenteditable="false" tabindex="-1" %)
Isak Björhag 40.1 44 (((
Isak Björhag 41.1 45
Isak Björhag 40.1 46 )))
47
Isak Björhag 28.1 48 == Getting started ==
Isak Björhag 12.1 49
50
Isak Björhag 59.1 51 First, download the wrapper and put the files into a folder. Please ensure that there are no special signs in the path to the folder. To get started, please check that the paths found inside the wrapper are correct for the (% class="mark" %)"Database dir"(%%) and (% class="mark" %)"Installation dir"(%%).
Iwona Budny Bjergø 42.1 52
53
Isak Björhag 65.1 54 |=(% style="background-color: rgb(29, 89, 152); width: 261px;" %)(% style="color:#ffffff" %)Download|=(% style="width: 1216px;" %)[[(% class="wikiattachmentlink" %)**⭳ API-wrapper (zip)**>>https://drive.google.com/a/strusoft.com/uc?authuser=0&id=1IL0CxJ0Uo7xGrFS7ojD1stzDcrixewp6&export=download]]
Iwona Budny Bjergø 42.1 55
Isak Björhag 63.1 56 (% contenteditable="false" tabindex="-1" %)[[image:1556029928168-186.png||data-widget="image" height="114" width="503"]]
Isak Björhag 12.1 57
Iwona Budny Bjergø 42.1 58
Isak Björhag 14.1 59 Now you are ready to open a new python file in the same folder as the wrapper. Import the wrapper with the import function:
60
Iwona Budny Bjergø 42.1 61
Isak Björhag 14.1 62 (% class="box infomessage" %)
63 (((
64 ##Import fdAPI_wrapper as fd##
65 )))
66
67 You can use a shortcut name to access the imported library of functions. In this example we use "fd". All functions and classes are now accessible by writing fd.<function>. For example fd.initiateModel('S').
68
Isak Björhag 7.2 69 == Classes ==
70
Isak Björhag 59.1 71 === {{id name="coord"/}}coord ===
Isak Björhag 7.2 72
73 (% class="box infomessage" %)
74 (((
75 (% style="background-color:null" %)##class coord:##(%%)
Isak Björhag 7.3 76 (% style="background-color:null" %)## def ~_~__init~_~__(self, x=0, y=0, z=0):##(%%)
Isak Björhag 8.1 77 (% style="background-color:null" %)## self.x = x##(%%)
78 (% style="background-color:null" %)## self.y = y##(%%)
79 (% style="background-color:null" %)## self.z = z##
Isak Björhag 7.2 80 )))
81
82 This class is used to define coordinates.
Isak Björhag 59.1 83 ##coord.x - x
84 coord.y - y
85 coord.z - z##
Isak Björhag 7.2 86
Isak Björhag 8.1 87
IwonaBudny 18.1 88 === XML ===
Isak Björhag 7.2 89
Isak Björhag 8.1 90 (% class="box infomessage" %)
91 (((
92 ##class XML:
93 def ~_~__init~_~__(self, filename = '', batch = '', export = ''):
94 self.filename = filename
95 self.batch = batch
96 self.export = export##
97 )))
98
Isak Björhag 59.1 99 This class is used to define the different file paths and names for the model file, batch export and csv output. The base folder is the place of the wrapper.
Isak Björhag 8.1 100
Isak Björhag 59.1 101 ##XML.filename## - path and filename of model file
102 ##XML.batch ##- path and filename of the batch export file
103 ##XML.export## - path and filename of the csv output from batch file
Isak Björhag 8.1 104
105
Isak Björhag 59.1 106 === {{id name="material"/}}material ===
Isak Björhag 8.1 107
108 (% class="box infomessage" %)
109 (((
110 ##class material:
111 def ~_~__init~_~__(self, type = '', creep = '', shrinkage = ''):
112 self.type = type
113 self.creep = creep
114 self.shrinkage = shrinkage##
115 )))
116
117 This class is used to define material parameters. It is used as input parameter when creating a material in the XML model file.
118
Isak Björhag 59.1 119 ##material.type## - material name as string
Isak Björhag 8.1 120
121 |**Concrete**|(% style="font-size:10px" %)C12/15|(% style="font-size:10px" %)C16/20|(% style="font-size:10px" %)C20/25|(% style="font-size:10px" %)C25/30|(% style="font-size:10px" %)C28/35|(% style="font-size:10px" %)C30/37|(% style="font-size:10px" %)C32/40|(% style="font-size:10px" %)C35/45|(% style="font-size:10px" %)C40/50|(% style="font-size:10px" %)C45/55|(% style="font-size:10px" %)C50/60|(% style="font-size:10px" %)C54/65|(% style="font-size:10px" %)C55/67|(% style="font-size:10px" %)C58/70|(% style="font-size:10px" %)C60/75|(% style="font-size:10px" %)C70/85|(% style="font-size:10px" %)C80/95|(% style="font-size:10px" %)C90/105
Isak Björhag 29.1 122 |**Steel**|(% style="font-size:10px" %)S235|(% style="font-size:10px" %)S275|(% style="font-size:10px" %)S355|(% style="font-size:10px" %)S420|(% style="font-size:10px" %)S450|(% style="font-size:10px" %)S460
123 |**Timber**|(% style="font-size:10px" %)C14|(% style="font-size:10px" %)C16|(% style="font-size:10px" %)C18|(% style="font-size:10px" %)C20|(% style="font-size:10px" %)C22|(% style="font-size:10px" %)C24|(% style="font-size:10px" %)C27|(% style="font-size:10px" %)C30|(% style="font-size:10px" %)C35|(% style="font-size:10px" %)C40|(% style="font-size:10px" %)C45|(% style="font-size:10px" %)C50|(% style="font-size:10px" %)D18|(% style="font-size:10px" %)D24|(% style="font-size:10px" %)D30|(% style="font-size:10px" %)D35|(% style="font-size:10px" %)D40|(% style="font-size:10px" %)D50
124 | |(% style="font-size:10px" %)D60|(% style="font-size:10px" %)D70|(% style="font-size:10px" %)L40s|(% style="font-size:10px" %)L40c|(% style="font-size:10px" %)GL 20h|(% style="font-size:10px" %)GL 22h|(% style="font-size:10px" %)GL 24h|(% style="font-size:10px" %)GL 26h|(% style="font-size:10px" %)GL 28h|(% style="font-size:10px" %)GL 30h|(% style="font-size:10px" %)GL 32h|(% style="font-size:10px" %)GL 36h|(% style="font-size:10px" %)GL 20c|(% style="font-size:10px" %)GL 22c|(% style="font-size:10px" %)GL 24c|(% style="font-size:10px" %)GL 26c|(% style="font-size:10px" %)GL 28c|(% style="font-size:10px" %)GL 30c
125 | |(% style="font-size:10px" %)GL 32c|(% style="font-size:10px" %)GL 36c| | | | | | | | | | | | | | | |
Isak Björhag 8.1 126
Isak Björhag 29.1 127 Service class 1 is assumed for all timber materials.
128
Isak Björhag 59.1 129 ##material.creep## - creep for concrete
130 ##material. shrinkage## - shrinkage for concrete
Isak Björhag 8.1 131
132
133 == Functions ==
134
IwonaBudny 18.1 135 === initiateModel ===
Isak Björhag 8.1 136
137 (% class="box infomessage" %)
138 (((
139 ##initiateModel(annex)##
140 )))
141
142 Use this function to initiate the base template for the XML model file. This needs to be done first before adding elements to the XML file.
143
144 ##annex ##- The selected annex for the model as a string
145
Isak Björhag 9.1 146 (% style="width:390px" %)
147 |(% style="width:128px" %)'GB' - Brittish|(% style="width:134px" %)'DK' - Danish|(% style="width:125px" %)'FIN' - Finnish
148 |(% style="width:128px" %)'D' - German|(% style="width:134px" %)'H' - Hungarian|(% style="width:125px" %)(((
Isak Björhag 8.1 149 'N' - Norwegian
150 )))
Isak Björhag 9.1 151 |(% style="width:128px" %)'PL' - Polish|(% style="width:134px" %)'RO' - Romanian|(% style="width:125px" %)'S' - Swedish
Isak Björhag 8.1 152
IwonaBudny 18.1 153 === finish ===
Isak Björhag 8.1 154
Isak Björhag 9.1 155 (% class="box infomessage" %)
156 (((
157 ##finish(filename)##
158 )))
Isak Björhag 8.1 159
Isak Björhag 9.1 160 This function will save and write the XML model file to the disk. It will also sort and indent the XML-file so that FEM-Design can read it. This function has to be ran before the file can be opened in FEM-Design.
161
162 ##filename - ##The location and filename of the XML file as a string, for example: ##'C:~\~\temp~\~\example.struxml'##
163
164
IwonaBudny 18.1 165 === addMaterial ===
Isak Björhag 9.1 166
167 (% class="box infomessage" %)
168 (((
169 ##addMaterial(material)
170 return material_ID##
171 )))
172
173 This function will add a material to the XML model file. The return value is used to assign the material to different objects.
174
Isak Björhag 59.1 175 ##material ##- The material to be added as a material class object. Please see above: class: [[material>>doc:||anchor="material"]]
Isak Björhag 9.1 176
177
IwonaBudny 18.1 178 === addSection ===
Isak Björhag 9.1 179
180 (% class="box infomessage" %)
181 (((
182 ##addSection(section, eccentricity)
183 return section_INFO##
184 )))
185
Isak Björhag 45.1 186 This function will add a section to the XML model file. The return value is used to assign the specific section to different objects. The section names can be found in this list: [[Section names>>https://drive.google.com/a/strusoft.com/uc?authuser=0&id=1bHHA1yokq3eJzGIbHrhtAPD2XU5ewOOl&export=download]]
Isak Björhag 9.1 187
188 ##section ##- This is the section name as a string
Isak Björhag 59.1 189 ##eccentricity ##- The eccentricity of the section as a coord object, see class: [[coord>>doc:||anchor="coord"]].
Isak Björhag 9.1 190
191
IwonaBudny 18.1 192 === addBeam ===
Isak Björhag 9.1 193
194 (% class="box infomessage" %)
195 (((
Isak Björhag 17.1 196 ##addBeam(section_INFO, material_ID, point1, point2, rotation, release)##
Isak Björhag 9.1 197 )))
198
199 This function will add a beam object to the XML model file. The beam is added as a line between two points, point1 and point2.
200
201 ##section_INFO## - The section of the beam. Return value from the addSection function
202 ##material_ID## - Material for the beam. Return value from the addMaterial function
Isak Björhag 59.1 203 ##point1## - Coordinate for the first point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
204 ##point2## - Coordinate for the second point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 27.1 205 ##rotation## - Rotation of the beam in degrees
Isak Björhag 9.1 206 ##release## - The end releases of the beam as a string: 'hinged' or 'fixed'
207
208
IwonaBudny 18.1 209 === addColumn ===
Isak Björhag 9.1 210
Isak Björhag 11.1 211 (% class="box infomessage" %)
212 (((
213 ##addColumn(section_INFO, material_ID, point1, height, rotation, release)##
214 )))
Isak Björhag 9.1 215
Isak Björhag 11.1 216 This function will add a column object to the XML model file. The column is inserted in a point with a specified height.
Isak Björhag 9.1 217
Isak Björhag 11.1 218 ##section_INFO ##- The section of the column. Return value from the addSection function
219 ##material_ID ##- Material for the beam. Return value from the addMaterial function
Isak Björhag 59.1 220 ##point1 ##- Coordinate for the insertion point of the column as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 221 ##height ##- Height of the column in meters
Isak Björhag 27.1 222 ##rotation ##- Rotation of the column in degrees
Isak Björhag 11.1 223 ##release ##- The end releases of the column as a string: 'hinged' or 'fixed'
Isak Björhag 9.1 224
225
IwonaBudny 18.1 226 === addTruss ===
Isak Björhag 9.1 227
Isak Björhag 11.1 228 (% class="box infomessage" %)
229 (((
Isak Björhag 27.1 230 ##addTruss(section_INFO, material_ID, point1, point2)##
Isak Björhag 11.1 231 )))
Isak Björhag 9.1 232
Isak Björhag 11.1 233 This function will add a truss object to the XML model file. The truss is added as a line between two points.
234
235 ##section_INFO## - The section of the truss. Return value from the addSection function
236 ##material_ID## - Material for the truss. Return value from the addMaterial function
Isak Björhag 59.1 237 ##point1 ##- Coordinate for the first point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
238 ##point2## - Coordinate for the second point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 239
240
IwonaBudny 18.1 241 === addPlate ===
Isak Björhag 11.1 242
243 (% class="box infomessage" %)
244 (((
245 ##addPlate(material_ID, thickness, release, point1, point2)##
246 )))
247
248 This function will add a plate as a rectangle with constant thickness to the XML model file. The release setting is set for all the edges of the plate.
249
250 ##material_ID ##- Material for the plate. Return value from the addMaterial function
251 ##thickness ##- Thickness of the plate in meters
252 ##release ##- The edge releases of the plate as a string: 'hinged' or 'fixed'
Isak Björhag 59.1 253 ##point1 ##- Coordinate for the first point of the rectangle as a coord object, see class: [[coord>>doc:||anchor="coord"]]
254 ##point2 ##- Coordinate for the second point of the rectangle as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 255
256
IwonaBudny 18.1 257 === addPlateComplex ===
Isak Björhag 11.1 258
259 (% class="box infomessage" %)
260 (((
261 ##addPlateComplex(material_ID, thickness, release, *points)##
262 )))
263
264 This function will add a plate with arbitrary shape defined by a series of lines to the XML model file. The plate is defined with constant thickness. The release setting is set for all the edges of the plate.
265
266 ##material_ID ##- The material of the plate. Return value from the addMaterial function
267 ##thickness ##- Thickness of the plate in meters
Isak Björhag 59.1 268 ##release## - The edge releases of the plate as a string 'hinged' or 'fixed'
269 ##p1, p2, p3... pi## - As many point input parameters as needed. Straight lines will be defined between the different points and between the first and last point. The coordinates defined with coord object, see class [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 270
Isak Björhag 63.1 271 (% contenteditable="false" tabindex="-1" %)[[image:1556012847391-857.png||data-widget="image" height="302" width="294"]]
Isak Björhag 11.1 272
273
IwonaBudny 18.1 274 === addWall ===
Isak Björhag 11.1 275
276 (% class="box infomessage" %)
277 (((
278 ##addWall(material_ID, thickness, release, point1, point2)##
279 )))
280
281 This function will add a wall object as a rectangle with constant thickness to the XML model file. The release setting is set for all the edges of the wall.
282
283 ##material_ID ##- Material for the wall. Return value from the addMaterial function
284 ##thickness ##- Thickness of the wall in meters
285 ##release ##- The edge releases of the wall as a string: 'hinged' or 'fixed'
Isak Björhag 59.1 286 ##point1 ##- Coordinate for the first point of the rectangle as a coord object, see class: [[coord>>doc:||anchor="coord"]]
287 ##point2 ##- Coordinate for the second point of the rectangle as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 288
289
IwonaBudny 18.1 290 === addPointSupport ===
Isak Björhag 11.1 291
292 (% class="box infomessage" %)
293 (((
294 ##addPointSupport(point, type)##
295 )))
296
297 This function will add a point support in the specified point to the XML model file.
298
Isak Björhag 59.1 299 ##point ##- Coordinate for the point support defined as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 300 ##type ##- The type of the support as a string: 'hinged' or 'fixed'
301
302
IwonaBudny 18.1 303 === addLineSupport ===
Isak Björhag 11.1 304
305 (% class="box infomessage" %)
306 (((
307 ##addLineSupport(point1, point2, type)##
308 )))
309
310 This function will add a line support as a line between the defined coordinates to the XML model file.
311
Isak Björhag 59.1 312 ##point1 ##- Coordinate for the first point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
313 ##point2 ##- Coordinate for the second point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 314 ##type ##- The type of the support as a string: 'hinged' or 'fixed'
315
316
IwonaBudny 18.1 317 === addSurfaceSupport ===
Isak Björhag 11.1 318
319 (% class="box infomessage" %)
320 (((
321 ##addSurfaceSupport(point1, point2)##
322 )))
323
324 This function will add a surface support as a rectangle to the XML model file. The support will be 'rigid' in x, y and z translation.
325
Isak Björhag 59.1 326 ##point1## - Coordinate for the first point of the rectangle as a coord object, see class: [[coord>>doc:||anchor="coord"]]
327 ##point2 ##- Coordinate for the second point of the rectangle as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 328
329
IwonaBudny 18.1 330 === addCover ===
Isak Björhag 11.1 331
332 (% class="box infomessage" %)
333 (((
334 ##addCover(point1, point2)##
335 )))
336
337 This function will add a cover object as a rectangle between two points.
338
Isak Björhag 59.1 339 ##point1 ##- Coordinate for the first point of the rectangle as a coord object, see class: [[coord>>doc:||anchor="coord"]]
340 ##point2 ##- Coordinate for the second point of the rectangle as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 341
342
IwonaBudny 18.1 343 === addLoadCase ===
Isak Björhag 11.1 344
345 (% class="box infomessage" %)
346 (((
347 ##addLoadCase(name, selfWeight)
348 return loadCaseID##
349 )))
350
351 This function will add a load case to the XML model file and return a load case ID which is used to assign different loads to a specific load case.
352
353 ##name ##- The name of the load case
354 ##selfWeight ##- If the program should generate self-weight of the modeled objects or not, input value: True or False
355
356
IwonaBudny 18.1 357 === addLoadComb ===
Isak Björhag 12.1 358
359 (% class="box infomessage" %)
360 (((
361 ##addLoadComb(nameLoadComb, type, loadCaseList, gammaLoadCases)##
362 )))
363
364 This function will add a load combination to the XML model file.
365
366 ##nameLoadComb ##- Name of the load combination
367 ##type ##- The type of the load combination as a string
368
369 (% style="width:210px" %)
370 |(% style="width:33px" %)**Type**
371 |(% style="width:33px" %) |(% style="width:40px" %)U|(% style="width:40px" %)Ua|(% style="width:35px" %)Us|(% style="width:36px" %)Sq|(% style="width:29px" %)Sf|(% style="width:33px" %)Sc
372
Isak Björhag 59.1 373 ##loadCaseList ##- List of load cases to be included in the load combination, return value of addLoadCase (##loadCaseID)##
374 ##gammaLoadCases ##- List of gamma values for the corresponding load cases
375
376
IwonaBudny 18.1 377 === addPointLoad ===
Isak Björhag 11.1 378
379 (% class="box infomessage" %)
380 (((
Isak Björhag 17.2 381 ##addPointLoad(force, direciton, loadCase, point)##
Isak Björhag 11.1 382 )))
383
384 This function will add a point load to the XML model file.
385
Isak Björhag 17.2 386 ##force ##- The magnitude of the point load in kilo newtons
Isak Björhag 59.1 387 ##direction ##- The direction of the point load as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 17.2 388 ##loadCase ##- The load case (##loadCaseID)## for the point load, return value from the addLoadCase function
Isak Björhag 59.1 389 ##point ##- Coordinate of the point load as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 390
391
IwonaBudny 18.1 392 === addLineLoad ===
Isak Björhag 11.1 393
394 (% class="box infomessage" %)
395 (((
Isak Björhag 17.2 396 ##addLineLoad(point1, point2, force, direction, loadCase, point1, point2)##
Isak Björhag 11.1 397 )))
398
399 This function will add a line load between two points to the XML model file.
400
Isak Björhag 12.1 401 ##force ##- The magnitude of the line load in kilo newtons per meter
Isak Björhag 59.1 402 ##direction ##- The direction of the line load as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 12.1 403 ##loadCase ##- The load case (##loadCaseID)## for the line load, return value from the addLoadCase function
Isak Björhag 59.1 404 ##point1 ##- Coordinate of the first point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
405 ##point2 ##- Coordinate of the second point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 406
407
IwonaBudny 18.1 408 === addSurfaceLoad ===
Isak Björhag 11.1 409
Isak Björhag 12.1 410 (% class="box infomessage" %)
411 (((
Isak Björhag 17.2 412 ##addSurfaceLoad(force, direction, loadCase, point1, point2)##
Isak Björhag 12.1 413 )))
Isak Björhag 11.1 414
Isak Björhag 12.1 415 This function will add a surface load as a rectangle between two points to the XML model file.
Isak Björhag 11.1 416
Isak Björhag 12.1 417 ##force ##- The magnitude of the surface load in kilo newtons per square meter
Isak Björhag 59.1 418 ##direction ##- The direction of the surface load as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 12.1 419 ##loadCase ##- The load case (##loadCaseID)## for the surface load, return value from the addLoadCase function
Isak Björhag 59.1 420 ##point1 ##- Coordinate of the first point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
421 ##point2 ##- Coordinate of the second point as a coord object, see class: [[coord>>doc:||anchor="coord"]]
Isak Björhag 11.1 422
423
IwonaBudny 18.1 424 === openFD ===
Isak Björhag 11.1 425
Isak Björhag 12.1 426 (% class="box infomessage" %)
427 (((
428 ##openFD(filename)##
429 )))
Isak Björhag 11.1 430
Isak Björhag 12.1 431 This function will open FEM-Design and the selected file.
Isak Björhag 11.1 432
Isak Björhag 12.1 433 ##filename ##- The filename and path from the working folder to the XML model file.
Isak Björhag 11.1 434
435
IwonaBudny 18.1 436 === runFD ===
Isak Björhag 12.1 437
438 (% class="box infomessage" %)
439 (((
440 ##runFD(analysis, save, close, design, filename, batchfile = '', exportfile = '')##
441 )))
442
443 This function will open FEM-Design and execute a script file which is build depending on the input parameters of the function.
444
445 ##analysis ##- Analysis type as a string, choose from 'LIN', 'NLE', 'NLE+PL', 'CR', '2ND', 'STAB' and 'IMP'
446 ##save ##- Save the model and result file or not, input: True or False
447 ##close ##- Close FEM-Design after the analysis is finished, input: True or False
448 ##design ##- Perform design check for steel, timber or concrete as a string: 'steel', 'RC', 'timber, or 'no'
449 ##filename ##- Name and path of the model from the working folder
Isak Björhag 59.1 450 ##batchfile ##- Name and path of the batchfile from the working folder (optional)
451 ##exportfile ##- Name and path of the export file from the working folder (optional)
Isak Björhag 7.2 452
Isak Björhag 51.1 453
Isak Björhag 52.1 454 = {{id name="Customize_wrapper"/}}Customize the wrapper =
Isak Björhag 51.1 455
Isak Björhag 57.1 456 The provided wrapper file is an example of how a wrapper file can look. It is of course possible to customize the wrapper to fit the specific needs of the project or workflow. The example wrapper provided in this wiki is limited in many ways to make it easy and fast to access the settings of the different object. If the user can modify the wrapper to unlock more settings for the different objects or add objects that are missing in the current version of the wrapper.
Isak Björhag 51.1 457
Isak Björhag 57.1 458 The wrapper file is build by different functions, one for each object to be added. In addition to this, some useful help-functions are also included. It is important to understand the help functions and what they do before changing the wrapper.
Isak Björhag 55.1 459
Isak Björhag 56.1 460 == Help functions ==
461
462 These functions are used to generate information in an effective way in the wrapper file. When there is an operation performed multiple times, it is generally made as a help-function. Below the different help functions is described in more detail.
463
Isak Björhag 55.1 464 === ID ===
465
Isak Björhag 56.1 466 (% class="box infomessage" %)
467 (((
468 ##ID(type)
469 return "X.X"##
470 )))
Isak Björhag 55.1 471
Isak Björhag 56.1 472 This function will keep track of the different littera used for the different objects. For example, if a beam is to be added, the function will return "B.<X>" where "X" is the number of the beam starting from 1.
473
Isak Björhag 64.1 474 ##type -## The type of the object as a string
475
Isak Björhag 56.1 476 === genGUID ===
477
478 (% class="box infomessage" %)
479 (((
480 ##genGUID()
481 return GUID##
482 )))
483
484 This function will generate and return a GUID as a string.
485
486 === genUTC ===
487
488 (% class="box infomessage" %)
489 (((
490 ##genUTC()
491 return UTC##
492 )))
493
494 This function will generate the time and date in the correct format for the struXML file and return it as a string.
495
496 === nmz ===
497
498 (% class="box infomessage" %)
499 (((
500 ##nmz(v)
501 return normalized##
502 )))
503
504 This function will normalize a vector.
505
506 ##v ##- A vector in 3D
507
508 === normal ===
509
510 (% class="box infomessage" %)
511 (((
512 ##normal(point1, point2, rot)
513 return normal_vector##
514 )))
515
516 This function will calculate the normal vector to a plane defined by three points. Point 1, point 2 and point1.z + 1.
517
518 ##point1 ##- Point 1 as a coord-object
519 ##point2## - Point 2 as a coord-object
520 ##rot## - Rotation in degrees
521
522
Isak Björhag 51.1 523 == Change the input parameters of a function ==
524
Isak Björhag 56.1 525 Open the wrapper file and go to the specific function. Change the input values of the function and add the input that is needed and add it to the XML creation part of the function. In this example we will add the possibility to set different end releases to the two ends of the beam object.
Isak Björhag 51.1 526
Isak Björhag 57.1 527 ~1. First find the beam object and add the input of another release.
Isak Björhag 55.1 528
Isak Björhag 56.1 529 (% class="box infomessage" %)
530 (((
531 ##def addBeam(section_INFO, material_ID, point1, point2, rotation, (% style="background-color:#f1c40f" %)release_start, release_end(%%)):##
532 )))
533
534 2. Identify the part of the wrapper that sets the end conditions of the beam.
535
536 (% class="box infomessage" %)
537 (((
538 ##if release == 'hinged':
539 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='false', r_z='false')
540 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='false', r_z='false')
541 else:
542 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='true', r_z='true')
543 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='true', r_z='true')##
544 )))
545
Isak Björhag 57.1 546 3. Rewrite the if statement to take into consideration the new inputs (there are many ways of writing this with python, this is just a simple and easy way to understand).
Isak Björhag 56.1 547
548 (% class="box infomessage" %)
549 (((
550 ##if release_start == 'hinged':
551 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='false', r_z='false')
552 if release_end == 'hinged':
553 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='false', r_z='false')
554 else:
555 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='true', r_z='true')
556 else:
557 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='true', r_z='true')
558 if release_end == 'hinged':
559 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='false', r_z='false')
560 else:
561 ET.SubElement(add_beam_child, 'connectivity', m_x='true', m_y='true', m_z='true', r_x='true', r_y='true', r_z='true')##
562 )))
563
564 Now the function will take two end release settings and change the XML file accordingly.
565
Isak Björhag 51.1 566 == Add a new function to the wrapper ==
567
Isak Björhag 57.1 568 The easiest way of adding new objects to the wrapper is to create them in FEM-Design and save it as struXML. Now study the created XML text to be able to understand it and recreate it.
Isak Björhag 51.1 569
Isak Björhag 57.1 570 It is mainly the command ##SubElement ##from the library Element tree that is used to add lines in the XML file. Please visit [[https:~~/~~/docs.python.org/2/library/xml.etree.elementtree.html>>url:https://docs.python.org/2/library/xml.etree.elementtree.html]] for a complete documentation.
571
572 It is also important to sort the XML file. This is done in the function called ##finish. ##This will sort the XML file by simply removing and adding the different objects in the XML file in the correct order.
Iwona Budny Bjergø 62.1 573
574 ----
575
576 (% style="text-align: justify;" %)
577 (% 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