Automating tasks using python script has become more and more common, especially in numerical modeling. When dealing with repetitive actions, structuring standard reports, and the need of going beyond the program’s limitations on data access. Actions in PLAXIS are translated into commands, which has an equivalent Python command. Therefore, PLAXIS provides the capability of connecting with remote scripting server and external API through Python language. So, with Python scripting files, user can create scripts interacting with the PLAXIS application.
Running the Python Script
The script available in this article explains how to create and adjust soil layer level in boreholes. Therefore, user can copy and utilize the base of the script in their own projects.
Now, the example below will set in the Input part in python:
s_i.new() #create new model
g_i.SoilContour.initializerectangular(0, 0, 25, 12) #Change the coordinates of the rectangular soil contour
bh1 = g_i.borehole(0) #Create a borehole object assigned to variable bh1
g_i.soillayer(0) #Add a soil layer
g_i.setsoillayerlevel(bh1, 0, 12) #Set Soil level Top of borehole bh1 to 12
g_i.setsoillayerlevel(bh1, 1, 8) #Set Soil level Bottom of borehole bh1 to 8
g_i.soillayer(0) #Add a soil layer
g_i.setsoillayerlevel(bh1, 2, 3) # Set Soil level bottom of borehole bh1 to 3
#alternative: add directly thinkness to soillayer
g_i.soillayer(3) #Add a soil layer with 3 units of Thickness
bh2 = g_i.borehole(25) #Create a borehole object assigned to variable bh2
# we already have soillayers
# change the top
g_i.setsoillayerlevel(bh2, 0, 10) #Set Soil level Top of borehole bh2 to 10
g_i.setsoillayerlevel(bh2, 1, 9) #Set Soil level Bottom of borehole bh2 to 9
Also, watch this video to learn how to create the mentioned borehole script with Python and with PLAXIS commands. The video will also provide an initial understanding on the anatomy of commands and important topic when correlating PLAXIS with Python Language.
NOTE : Additionally, all the techniques of python in PLAXIS are discussed in the following featured trainings:
OnDemand Training | PLAXIS: Introduction to Python
OnDemand Training | PLAXIS: Result Post-Processing Automation in PLAXIS Output
OnDemand Training | PLAXIS: Advanced Features and Practical Examples of Python Scripting