Using PLAXIS Remote scripting with the Python wrapper


 

Application PLAXIS 2D
PLAXIS 3D
Version PLAXIS 2D CONNECT Edition V20 and later
PLAXIS 3D CONNECT Edition V20 and later
Date created 29 April 2015
Date modified 24 July 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 PLAXIS 2D and PLAXIS 3D:

Configure remote scripting server window.png

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

For the Remote Scripting server to run, you would need:

  1. A valid Bentley Geotechnical SELECT Entitlement [GSE] (former PLAXIS-VIP) license
  2. 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.
  3. The local connection port needs to be configured and the server activated

Remote scripting server requirements.png

Figure 2. Run the remote scripting server requirements:
1) a valid license, 2) a password and 3) a local connection port

Boilerplate code

In order to start your first Python script, you can start SciTE from PLAXIS. 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.

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')

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