...
Table of Contents | ||||
---|---|---|---|---|
|
1. Setting a Python Development Environment
1.1 Python Install download
Download an installing file from the Python official website.
...
* You can find various OS installers besides the Window.
1.2 Install Python
Install Python.
...
These editors offer a convenient developing environment for users.
...
(This manual is written using Visual Studio Code.)
1.3 Install additional module
You can control MIDAS/Civil API only when installing the Request Module in Python.
...
Code Block | ||
---|---|---|
| ||
py -3 -m pip install requests |
2. Operating MIDAS/Civil API using Python
Let’s see how MIDAS/Civil API works with simple examples.
2.1 Operating MIDAS/Civil API
To communicate with the API, Civil is executable as follows.
...
The user can change the MIDAS/Civil file path depending on their work environment.
2.2 Open MIDAS/Civil API documnent
We are opening a saved file after executing MIDAS/Civil API.
...
The user can find an URL in the APIServer.exe when executing MIDAS/Civil through API.
...
2.3 MIDAS/Civil API - Run the Analysis and Close program
Now, run the analysis with opened MIDAS/Civil file and close the Civil.
...
Code Block | ||
---|---|---|
| ||
## DOC.ANAL requests.post(CIVIL_API_URL + "/doc/anal", json={}) ## DOC.EXIT requests.post(CIVIL_API_URL + "/doc/exit", json={}) |
3. Command for operating
3.1 DOC Command
DOC command controls documents such as create/open/close files
...
Code Block | ||
---|---|---|
| ||
import requests #String = MCB file path (ex : "C:\\Json\\Example.json") requests.post("http://127.0.0.1:10024/doc/export", json={"Argument":String}) |
3.2 DB Command
DB Command requests the data name. Each Data name is embodied GET/POST/PUT/DELETE methods.
...
Code Block | ||
---|---|---|
| ||
import requests CIVIL_API_URL = "http://127.0.0.1:10024" ## Delete db/node requests.delete(CIVIL_API_URL + "/db/node") |
3.3 POST Command
Post Command is post-process operators after analysis.
...
Code Block | ||
---|---|---|
| ||
import requests import json CIVIL_API_URL = "http://127.0.0.1:10024" ## POST /POST/TABLE Anal_Result=requests.post(CIVIL_API_URL + "/post/table",json={ "Argument": { "TABLE_TYPE": "beam force", "UNIT": { "FORCE": "KN", "DIST": "M", "HEAT": "CAL", "TEMP": "C" }, "NODE_ELEMS": { "TO": "1003 to 1013" }, "LOAD_CASE_NAMES": [ "ULS_SET B(CB:max)", "ULS_SET B(CB:min)", "ULS_EQ(CB:max)", "ULS_EQ(CB:min)" ], "PARTS": [ "Part I", "Part J" ] } }).text Anal_Result=json.loads(Anal_Result) Anal_IntForc=Anal_Result['empty']['DATA'] print(Anal_IntForc[0]) |
3.4 VIEW Command
View Command takes images in Post-process.
...