Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
GeoStudio | PLAXIS
  • Product Communities
GeoStudio | PLAXIS
GeoStudio | PLAXIS Wiki Using PLAXIS Remote scripting with the Python wrapper
    • Sign In
    • -Geotechnical Analysis Wiki
      • +GeoStudio
      • -PLAXIS
        • +Software and License - PLAXIS
        • +Documentation - PLAXIS
        • +API / Python scripting - PLAXIS
        • +Known issues - PLAXIS
        • +Models - PLAXIS
        • -Tips and Tricks
          • 3D Extrusion along a curved path
          • 3D Output: show results for shadings or contour lines
          • 64 bit User Defined Soil model
          • After a consolidation analysis I have excess pore pressures in "drained" material sets. Why?
          • An error occurred in the application – What to do
          • Application of commands: echo
          • Application of commands: Groupfiltered and Apply
          • Application of commands: Referring to objects through their index
          • Calculation Kernel Convergence log
          • Can I import a geometry in PLAXIS 2D?
          • Can I reuse existing PLAXIS 3D geometrical objects in a new project?
          • Change temporary folder for intermediate calculation data files
          • Closing PLAXIS after your calculation is finished
          • CodeMeter network error during calculation (IPv4/v6 conflict)
          • Codemeter Network Installation
          • Codemeter USB Stick behaviour
          • Command line reference
          • Compliant base and free field boundaries: check on input signal
          • Composite liner approach in PLAXIS 2D
          • Connect a node-to-node anchor with an embedded beam row halfway
          • Considerations for modelling a thick slab as a plate
          • Consolidation: Minimum Pore Pressures and Degree of Consolidation analysis may give spurious displacements of boundary nodes
          • Conversion from 2D Version 8/9
          • Conversion of PLAXIS 2D files
          • Copy/Array command in Plaxis 2D
          • Create centerline for Structural Forces in Volumes
          • Create rock bolts accurately in PLAXIS 3D
          • Creating axial force curve for Fixed End anchors
          • Deactivated loads are still visible in PLAXIS Output
          • Definition of a bending moment as load
          • Definition of Hoek-Brown model parameters in Plaxis
          • Drained Settlement Vs. Consolidation: Differences at Failure in Output
          • Drift correction for dynamic input signal from file
          • During a calculation some plastic points disappear. How is that possible?
          • Dynamic Load with Perpendicular Distribution
          • Encrypted scripting server vulnerable to replay attacks
          • End bearing of plates
          • Energy saving while running multiple calculations
          • Error when generating 3D mesh
          • Export and format plots from PLAXIS Output
          • Export or reuse geometry for New Analysis
          • Extended command syntax for mesh generation
          • Fixed and Compliant base: what input motion is required?
          • Fixities and deformation boundary conditions
          • Force envelope results explained
          • Fundamentals of pseudo-static analysis in PLAXIS
          • General modeling guidelines - recommendations
          • Graphics card issues
          • Groundwater flow analysis in PLAXIS – Brief overview
          • How do I import a geometry in PLAXIS 3D?
          • How does Plaxis deal with water pressures during dynamic calculations?
          • How does Reset displacements to zero work?
          • How does the option volumetric strain work?
          • How to activate a dynamic load
          • How to change the PLAXIS model width
          • How to check undrained shear strength using Undrained A?
          • How to convert PLAXIS V21 material database to the V22 format
          • How to define and edit a material via the command line
          • How to get a load - displacement curve using SumMstage
          • How to prescribe a dynamic displacement
          • How to run a Limit Equilibrium Method analysis from PLAXIS 2D
          • How to select more than 10 nodes to be used for a curve
          • How to setup the number of steps stored in PLAXIS Input
          • How to setup tied degrees of freedom
          • How to use command log files
          • How to validate a material via the GUI and command line
          • Hydraulic conductivity input in PLAXIS using van Genuchten functional forms in a groundwater flow analysis
          • I use PLAXIS and it says I do not have the proper entitlements
          • Improving speed of mesh generation in combination with stage generation
          • In Plaxis Curves it is possible to plot Force Fx, Fy and Fz. What are these parameters?
          • Initial degree of saturation for soil activated during staged construction
          • InputSettings object in Output
          • Inspect intermediate step results in PLAXIS Output
          • Install latest 2D version and 2D AE for converting older files
          • Is it possible to apply a distributed load on tunnel lining in PLAXIS 2D?
          • Is PLAXIS 3D 64-bit?
          • Is PLAXIS 3D enabled for multicore?
          • Iterative settings: desired minimum and maximum
          • Iterative settings: Influence of Arc length control
          • Iterative settings: Max unloading steps (arc length control)
          • Key not bound to machine
          • Language reset in PLAXIS 2D and 3D
          • Launch PLAXIS 2D calculations via DOS commands
          • Load activation in time
          • Local axis and its colour indication
          • Macros using the commands runner
          • Material datasets for plates: sheet pile wall in bending
          • Materials overview in the Model explorer
          • Memory usage in dynamic calculations
          • Mesh alignment in flow problems
          • Mesh generation might not work under Windows 7 due to security settings
          • Modelling a tapered pile
          • Modelling Rock mass using discrete discontinuities vs Jointed Rock
          • Modelling soil-structure interaction: interfaces
          • Modelling technique: Vacuum consolidation
          • Modifying boundary conditions
          • Multicore CPU and 32/64-bit
          • NATM Tunneling - Beta Method: Incomplete Staged construction method vs. Deconfinement method
          • Node-to-Node anchors as an alternative for Fixed-End anchors
          • Non-consecutive order of step numbers in Plaxis
          • Obtain Object names easily to use in commands
          • Obtaining tabulated data from PLAXIS Input
          • Obtaining time-dependent flow results at specific timestamps in a given time interval in Flow only calculations
          • On different failure criteria for soils
          • On the initialisation of the temperatures of solid elements
          • On the use of dynamic boundary conditions
          • Opening old PLAXIS project gives a popup window. What should I do?
          • Output of flow results through interfaces
          • Output project compatibility
          • Permeability in interfaces
          • Permeability in interfaces: Practical situations
          • Pile modelling in a 2D plane strain model
          • PLAXIS 2D Command compatibility notes
          • PLAXIS 3D 2013 and older PLAXIS files
          • PLAXIS 3D 2016: Fully parametric geometry
          • PLAXIS 3D Command compatibility notes
          • PLAXIS Legacy version and supported CodeMeter drivers
          • PLAXIS Output Phase/Step object compatibility
          • PLAXIS Silent Installation
          • PLAXIS Soil model numbers in command line
          • Plaxis uses SMC files for earthquakes, but what kind of format is this?
          • Points of interest for pile modelling in a 2D plane strain model
          • Problems related to non-associated plasticity
          • Program responds that drivers are out of date, but I have a newer version installed
          • Pseudo static acceleration
          • Re-use materials from other projects
          • Reduction of stiffness does not lead to a change in displacements
          • Regenerate staged construction
          • Run multiple calculations easily
          • Safety analysis and displacements
          • Safety analysis and undrained behaviour
          • Safety analysis and Updated Mesh
          • Safety calculation with a Target Value
          • Saving PLAXIS files for an older version
          • Select points for curves prior to calculation directly in Input
          • Selecting points for curves
          • Set multiple phases to be calculated
          • Showing a list of embedded beams by length
          • Small overlaps curves message in SoilTest optimisation
          • Smart selection of line elements in PLAXIS 2D Input
          • Stiffness units for structural elements in an axisymmetric model
          • Stress relaxation due to creep in concrete structures
          • Stresses in non-porous materials
          • Structural results in tables and curve plots
          • Swept meshing in PLAXIS 3D
          • Tensile behaviour in the Hoek-Brown model
          • Tension cut-off in interfaces for User Defined Soil Models
          • Time step used in dynamic calculation
          • Trim and extend a line in PLAXIS 2D
          • Tunnels in PLAXIS 3D: Extrusions and cutting planes
          • Unable to select points for curves
          • Unable to select structures or nodes
          • Use of wells in PLAXIS 3D
          • Using an accelerogram for Dynamics
          • Using partial geometry for interesting result images in PLAXIS 3D
          • Using PLAXIS Remote scripting with the Python wrapper
          • Waterlevel inspection and editing in PLAXIS 2D
          • Westergaard's added mass for hydrodynamic pressures: a simple case
          • +Working from home with PLAXIS
        • +Publications
        • +Videos - PLAXIS
      • +PLAXIS Monopile Designer
      • +PLAXIS LE
      • +SOILVISION
      • +Geotechnical SELECT Entitlements [GSE]
      • +Subscription Entitlement Service

     
     Questions about this article, topic, or product? Click here. 

    Using PLAXIS Remote scripting with the Python wrapper

    Application PLAXIS 2D
    PLAXIS 3D
    Version PLAXIS 2D
    PLAXIS 3D
    Date created 29 April 2015
    Date modified 04 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:

    • a Bentley Geotechnical SELECT Entitlement [GSE] (former PLAXIS-VIP) license is required
    • An editor for writing Python scripts in. This article assumes that the SciTE editor will be used that comes with the PLAXIS installation. SciTE is also in the Windows Start menu in the folder of PLAXIS programs with the name “Python editor for PLAXIS 2D”.
      The relevant option is also available for PLAXIS 3D, too.
    • At least a very rudimentary knowledge of the Python language is recommended. The Plaxis documentation makes no attempt to teach it. Good resources for this purpose are e.g.:
      • Dive into Python 3: http://diveintopython3.problemsolving.io/
      • After hours programming: http://www.afterhoursprogramming.com/tutorial/Python/Overview/
      • Think Python: How to Think Like a Computer Scientist: http://greenteapress.com/thinkpython/html/index.html
    • The firewall should not block the PLAXIS application from accessing the internet, nor must it block other applications (in particular the python.exe and pythonw.exe executable) from communicating with the remote scripting server inside the PLAXIS application.

    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:

    • 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).

    For PLAXIS Output, the recommended variable names are:

    • s_o: this is bound to an object representing the PLAXIS Output Application (the Remote scripting server).
    • g_o: this variable is bound to the global object of the current open Plaxis model in Output. This should be used when you want to access Output objects (e.g. retrieve results, set up a plot, switch to a specific phase).

    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:

    • Is the PLAXIS application running?
    • Is the Remote Scripting server inside PLAXIS activated with the same port number as used in the Python script?
    • Is the firewall blocking communications with the PLAXIS application?
    • [2D only] Is the password given to new_server the same as the one in the ‘configure remote scripting server’ dialogue?

    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

    • PLAXIS_older_versions_Using_PLAXIS_Remote_scripting_with_the_Python_wrapper.pdf

    See also

    How to get a load - displacement curve using Scripting interface    [Python Scripts]


    Command line reference    [Tips and Tricks]


    Output scripting example: create curve data    [Python Scripts]


    Output scripting example: get anchor force    [Python Scripts]


    Output scripting example: get heave of excavation bottom    [Python Scripts]


    Output scripting example: get maximum bending moment    [Python Scripts]


    Identify Python commands from Plaxis command line    [Python Scripts]


    Receive instant notifications for finished calculations on your phone    [Python Scripts]

    • Rest Http
    • PLAXIS 3D
    • python
    • API
    • Scripting
    • PLAXIS
    • Remote scripting
    • boilerplate
    • wrapper
    • PLAXIS 2D
    • Share
    • History
    • More
    • Cancel
    • Micha van der Sloot Created by Bentley Colleague Micha van der Sloot
    • When: Mon, Dec 23 2019 7:12 AM
    • Micha van der Sloot Last revision by Bentley Colleague Micha van der Sloot
    • When: Mon, Apr 4 2022 3:34 AM
    • Revisions: 4
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies