PLAXIS Older Versions Using PLAXIS Remote Scripting With The Python Wrapper
PLAXIS Older Versions Using PLAXIS Remote Scripting With The Python Wrapper
wrapper
29 APRIL 2015
The PLAXIS software provides a HTTP based API (REST HTTP API), for which a special Python wrapper
was developed to for an easy to use scripting API. Both PLAXIS Input and PLAXIS Output support this
usage of a Remote Scripting server.
Prerequisites
In order for the Remote Scripting server to run, you would need:
Boilerplate code
In order to start your first Python script, you must make sure that your Python script can
communicate with the PLAXIS application. For this, the Plaxis scripting library wrapper needs to
be imported as a module and the correct port needs to be set. For a locally running PLAXIS
application this can easily be achieved using the following boilerplate Python code to start your
Python script with (assuming the scripting server port was set to 10000, see above):
localhostport = 10000
plaxis_path = r'C:\Program Files (x86)\Plaxis\PLAXIS 2D' #no trailing backslash!
import imp
found_module = imp.find_module('plxscripting', [plaxis_path])
plxscripting = imp.load_module('plxscripting', *found_module)
from plxscripting.easy import *
In this, we need to set the correct localhost port using the same number as set in the Configure
remote scripting server window. Next we need the location where the PLAXIS application is
installed: plaxis_path. From this location we will import the plxscripting module to allow for the
communication with the Plaxis application.
s_i: this is bound to an object representing the PLAXIS Input Application (the Remote
scripting server).
g_i: this variable is bound to the global object of the current open Plaxis model in Input.
This should be used when you want to make changes to the model (e.g. adding a borehole or
a point, generating the mesh and start the calculation).
#[...]
localhostport_input = 10000
localhostport_output = 10001
s_i, g_i = new_server('localhost', localhostport_input )
s_o, g_o = new_server('localhost', localhostport_output )
Trouble shooting
If your script gives an error, please check the following:
For more details on this Python wrapper and some code examples, please see the appendix on the
Python HTTP REST API wrapper in the PLAXIS Reference manual and the related links.