python API boilerplate code

I would like to access the python API using external application. In previous versions of Plaxis, i had to add the following boilerplate at the beginning:

import imp,sys
sys.path.append("C:\Program Files\Plaxis\PLAXIS 2D\python\Lib\site-packages")
plaxis_path = r'C:\Program Files\Plaxis\PLAXIS 2D\python\Lib\site-packages'
found_module = imp.find_module('plxscripting', [plaxis_path])
plxscripting = imp.load_module('plxscripting', *found_module)
from plxscripting.easy import *
localhostport0 = 10000
s_i, g_i = new_server('localhost', localhostport0, password='*PASSWORD*')

What is the boilercode for the Plaxis CE version?

Parents
  • OK, how can I install additional modules in this environment (pip install ...)?

    What about, if I would like to use another environment, e.g. IDLE, what boilerplate code should I use then to access plaxis?

  • Dear Sasa,

    You can install a third-party package via our Command prompt.

    As this requires administrator rights on your PC, you first need to launch PLAXIS Input or Output as Administrator. This can be done by click with RMB on the PLAXIS shortcut and selecting Run as Administrator.

    Then, open the command prompt from Expert > Python > Command prompt in PLAXIS Input or Output program.

    In the Command prompt, you can install new packages by using pip. For example, if you want to install the dropbox package you would type:

    python -m pip install dropbox

    Running a different environment means that you would need all the modules PLAXIS provides to allow for communication. As a solution and in order to prevent any conflicts between different Python distributions, we suggest pointing to the Plaxis Python distribution from this IDE to launch the correct Python distribution. By default the path for the Python distribution is:
    C:\ProgramData\Bentley\Geotechnical\PLAXIS Python Distribution v1.0.0

    Then, your IDE, e,g, Spyder, PyCharm, can know which Python version to run, including the modules we test and know that work well with PLAXIS.

  • Stefanos, thanks for the answer. Spyder and Pycharm are a bit of overkill for my needs, however a simple SciTE is enough for data extraction from Plaxis Output.

Reply Children
No Data