Application | PLAXIS 2D PLAXIS 3D |
Version | PLAXIS 2D PLAXIS 3D |
Date created | 28 October 2015 |
Date modified | 11 April 2024 |
Since PLAXIS CONNECT Edition V20, extensive documentation is available regarding the Remote Scripting functionality.
This can be found under Help > Scripting reference menu:
More information on the Scripting reference can be found in the article Scripting reference and how to use it.
The basics for starting the Remote Scripting and starting using the Python wrapper to interact with PLAXIS can be found in the PLAXIS Reference manual's Appendices and the article Using PLAXIS Remote scripting with the Python wrapper.
The first step to identifying the command syntax when using the Python scripting functionality is to understand the Plaxis native commands.
Inside the PLAXIS programs, you can access the full Commands and Objects reference under the Help > Command reference menu. This will open an HTML-based documentation on your default browser. See also Command line reference.
The Commands and Object reference describes how to directly use the Commands in the PLAXIS Command line. With this, it is easy to construct the command to be used inside the Python wrapper:
In the examples below, we used the boilerplate code example from this page Using PLAXIS Remote scripting with the Python wrapper, i.e. we can refer to g_i as the global object of the current open PLAXIS model in the Input program.
PLAXIS command | borehole 5 |
Python equivalent |
g_i.borehole(5) |
PLAXIS command | point 1 2 |
Python equivalent |
g_i.point(1, 2) |
Setting a single value to a so-called intrinsic property can be achieved using different Python syntax:
PLAXIS command | set Point_1.x 9.3 |
Python equivalent (recommended) |
g_i.Point_1.x = 9.3
|
alternatives in Python |
g_i.Point_1.x.set(9.3) |
Setting the Conditions property of the WaterConditions of a BoreholePolygon's Soil object (for PLAXIS 2D; in PLAXIS 3D that is BoreholeVolume) in Staged construction can be achieved using a different Python syntax:
PLAXIS command | set WaterConditions_1_2.Conditions Phase_1 "Dry" |
Python equivalent (recommended) |
g_i.WaterConditions_1_1.Conditions[g_i.Phase_1] = "Dry" |
alternatives in Python |
g_i.BoreholePolygon_1_1.Soil.WaterConditions.Conditions[g_i.Phase_1] = "Dry" |
Practically, sometimes it is useful to use the info and echo command in the PLAXIS Input program to get more details about an object. For instance when using it for the Colours object or for a point object Point_1 to obtain more info about the available parameters and their spelling, and to see which commands and attributes are available:
0010> echo Colours Colours named "Colours" 0011> info Colours Colours Commands: echo, commands, rename, set, info, setproperties Attributes: Apple, Aqua, BabyBlue, Black, BlackBerry, Blue, Brown, ... 0012> echo Point_1 Point named "Point_1" x: 5 y: 5 0013> info Point_1 Point_1 Commands: echo, commands, rename, set, info, setproperties, movedisconnected Attributes: Name, Comments, UserFeatures, x, y, z
A practical tip if you are trying to figure out what command to use in Python, is to do the action you want to perform by using the mouse and keyboard in the Graphical User Interface (GUI) and read the generated command in the Command Session pane. Then, this command should be easily transferable into a Python command.
Example: change the top of a borehole
In order to do this via the GUI, we need to open the Modify soil layers window and change the top of the first soil layer. e.g. we change it to y = 2 m:
This will generate the following command to apply the change from which we can create the Python equivalent:
PLAXIS command | _set Soillayer_1.Zones[0].Top 2 |
Python equivalent |
g_i.Soillayer_1.Zones[0].Top = 2
|
Alternatively, this can be configured using the setsoillayerlevel command. For more documentation on the specific parameters for the used setsoillayerlevel command or any other command, please refer to the Commands reference.
For more details on this Python wrapper and some code examples, please see the article on Scripting reference and how to use it and the appendix on the Python HTTP REST API wrapper in the PLAXIS Reference manuals.
In the PLAXIS wiki, you can also find some scripting examples which can be used as a basis for your own Python script.