Using PLAXIS Remote scripting with the Python wrapper


ApplicationPLAXIS 2D
PLAXIS 3D
VersionPLAXIS 2D
PLAXIS 3D
Date created29 April 2015
Date modified04 April 2022

The PLAXIS software provides an HTTP based API (REST HTTP API), for which a special Python wrapper was developed for an easy to use scripting API. Both PLAXIS Input and PLAXIS Output support this usage of a Remote Scripting server.

The information in this article applies to both 2D and 3D 2017 versions and later, as well as to 3D 2016 version. For older versions, please see the attachment at the end of this article.

Prerequisites

In order to use this:

Activate scripting server

In order to start using this Remote Scripting/REST HTTP API, the remote scripting server inside PLAXIS needs to be activated. This can be done by opening the menu item Expert > Configure remote scripting server. The corresponding window will pop up, see Figure 1 for the latest versions of PLAXIS 2D and PLAXIS 3D and Figure 2 for PLAXIS 3D 2016:

Figure 1. Configure remote scripting server window in PLAXIS 2D and PLAXIS 3D

 


Figure 2. Configure remote scripting server window in PLAXIS 3D 2016

In order for the Remote Scripting server to run, you would need:

PLAXIS 2D 2017 and later, PLAXIS 3D 2017 and later

  1. A valid Bentley Geotechnical SELECT Entitlement [GSE] (former PLAXIS-VIP) license
  2. A working HTTP connection to the Plaxis Remote scripting Authorization site (i.e. a working internet connection)
  3. A password to ensure a secure connection between the server and the remote scripting interface. PLAXIS Input generates by default a password.
    Be aware that an empty text box disables the encryption.
  4. The local connection port needs to be configured and the server activated

Figure 3. Run the remote scripting server requirements:
1) valid license, 2) connection with the Remote Plaxis service website, 3) password
and 4) a local connection port

PLAXIS 3D 2016

  1. A valid Bentley Geotechnical SELECT Entitlement [GSE] (former PLAXIS-VIP) license
  2. A working HTTP connection to the Plaxis Remote scripting Authorization site (i.e. a working internet connection)
  3. The local connection port needs to be configured and the server activated

Figure 4. Run the remote scripting server requirements:
1) valid license, 2) connection with the Remote Plaxis service website
and 3) a local connection port

Boilerplate code

In order to start your first Python script, you can start SciTE from the Windows Start menu. First, we must import the Plaxis scripting library. Then, you must make sure that your Python script can communicate with the PLAXIS application (assuming the scripting server port was set to 10000, see above):

from plxscripting.easy import *
s_i, g_i = new_server('localhost', 10000, password='yourpassword')

In this, we need to set the correct localhost port using the same number as set in the Configure remote scripting server window as well as the password field required (PLAXIS 2D only).

Now we have two new variables:

For PLAXIS Output, the recommended variable names are:

PLAXIS Input and PLAXIS Output

Note, if you want to use both PLAXIS Input and PLAXIS Output in your Python script, you will need to set up the connection with Input and Output separately by binding the server and the global object for Input and Output separately using each their own port number:

# PLAXIS 2D and PLAXIS 3D
# [...] 
localhostport_input = 10000 
localhostport_output = 10001
from plxscripting.easy import *
s_i, g_i = new_server('localhost', localhostport_input, password='yourpassword') 
s_o, g_o = new_server('localhost', localhostport_output, password='yourpassword')

For older versions of PLAXIS 3D you can use the following boilerplate:

# PLAXIS 3D
# [...] 
localhostport_input = 10000 
localhostport_output = 10001
from plxscripting.easy import * 
s_i, g_i = new_server('localhost', localhostport_input) 
s_o, g_o = new_server('localhost', localhostport_output)

Troubleshooting

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.

Starting January 1st, 2022, the PLAXIS HWL versions and the VIP subscription have been discontinued. This includes access to the PLAXIS Remote Scripting services for these versions. To allow time for transition to the PLAXIS CONNECT Edition version, the Remote Scripting Server services for PLAXIS HWL versions will continue to function until December 31, 2022. After this date, the Remote Scripting Server services will be discontinued.

Downloads

See also