Quantcast
Channel: PLAXIS - Knowledge Base - PLAXIS 2D
Viewing all articles
Browse latest Browse all 43

Python commands reference

$
0
0
Application:

Commands reference

There is extensive documentation available for when using the Python wrapper for the Remote Scripting functionality: inside the Plaxis programs that support this Remote Scripting you can access the full Commands and Objects reference via the help menu. This will open an HTML based documentation.
See also Command line reference

The basics for starting the Remote Scripting and start using the Python wrapper to interact with Plaxis, can be found in the PLAXIS Reference manual's Appendices and here Using PLAXIS Remote scripting with the Python wrapper

Plaxis Commands in Python

This 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:

  • To call a command, prefix the command with the global object reference (in the boilerplate referred to as g) and add the parameters in brackets
  • To refer to a Plaxis object, prefix the Plaxis object name also with this global ojbject reference.

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 as the global object of the current open Plaxis model.

Add a borehole in PLAXIS 2D

Plaxis commandborehole5
Python equivalent
g.borehole( 5 )

Add a point in PLAXIS 2D

Plaxis commandpoint12
Python equivalent
g.point( 1, 2 )

Change the x-coordinate for a point

Setting a single value to a so-called intrinsic property can be achieved using different Python syntax:

Plaxis commandsetPoint_1.x9.3
Python equivalent
g.set( g.Point_1, 9.3 )
 
g.Point_1.set(9.3)
 
g.Point_1 = 9.3

Info and Echo

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> echoColoursColours named "Colours"0011> infoColoursColours    Commands: echo, commands, rename, set, info, setproperties    Attributes: Apple, Aqua, BabyBlue, Black, BlackBerry, Blue, Brown, ...  0012> echoPoint_1Point named "Point_1"  x: 5    y: 5  0013> infoPoint_1Point_1    Commands: echo, commands, rename, set, info, setproperties, movedisconnected     Attributes: Name, Comments, UserFeatures, x, y, z 

Practical tip to obtain Python command

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_setsoillayerlevelBorehole_102
Python equivalent
g.setsoillayerlevel( g.Borehole_1, 0, 2 )

For more documentation on the specific parameters for the used setsoillayerlevel command, or any other command, please refer to the Commands reference.

Python wrapper script examples

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 manuals. In the Plaxis Knowledge Base you can also find some scripting examples which can be used as a basis of your own Python script. Please see the related pages below.


Viewing all articles
Browse latest Browse all 43

Trending Articles