Repository navigation
Expand file tree
/
Copy pathAPI_setup.txt
More file actions
25 lines (13 loc) · 2.25 KB
/
Copy pathAPI_setup.txt
File metadata and controls
25 lines (13 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Written by William Easdown Babb, 7/12/2023.
These instructions will help you set up GMAT's Python API, using its default configuration. To use versions of Python later than 3.9, follow these instructions then those in README.txt.
1) Go into the GMAT root folder (containing folders called api, bin etc). We'll call this [GMAT]. Go to [GMAT]/bin. If there is already a file in there named api_startup_file.txt, delete it.
2) If you will be using Python 3.6 to 3.9, go to 3). If you want to use a Python version later than 3.9, go to [GMAT]/bin and open gmat_startup_file.txt. In the Plugins section, find the line "PLUGIN = ../plugins/libPythonInterface_py39" and change 39 to match the Python version you want to use (e.g. 312 for Python 3.12). If you might use the alpha plugin for external force models, make the same modification to the line ending with "../plugins/libExternalForceModel_py39". Note that once you've finished following the instructions in this file, you must also do the steps in README.txt to set up non-default Python versions.
3) Go to [GMAT]/api, then double click BuildApiStartupFile.py to run it. A black window will briefly flash up on the screen. A new api_startup_file.txt will have been created in [GMAT]/bin.
4) Go to [GMAT]/api, and open load_gmat.py in a text editor (don't run it). You can do this by right clicking, then Open with, Choose another app, select Notepad and select Just once.
5) Change the GmatInstall variable from <TopLevelGMATFolder> to the path for [GMAT], making sure you keep the quotes around it. You can get the [GMAT] path by going back to its File Explorer window, right clicking the address and the top and clicking Copy Address as Text. Then paste this between the quotes on the GmatInstall line of load_gmat.py.
6) Python doesn't like the single backslashes that Windows puts in file addresses, so put an extra backslash in front of each existing one. The line should now read something like:
GmatInstall = "C:\\Users\\{username}\\Downloads\\gmat-win-R2022a\\GMAT"
7) Copy the file load_gmat.py to the same folder as wherever your Python code will live.
8) At the start of any Python file where you want to use the GMAT API, add the following line:
from load_gmat import gmat
9) You can then call the API with commands like gmat.Help()