Hello everyone,
I am a complete beginner with Python as well as the Python scripting for Plaxis use.
I have searched through the web and the Bentley Communities and I couldn't find any topic related to basic scripting such as drawing simple geometries and a simple use of Python in general.
Therefore my discussion topic for beginners.
My first question is (very basic... I know, but I have no clue how to deal with it...)
Why does my script doesn't work (Plaxis 2D) ?
from plxscripting.easy import *s_i, g_i = new_server('localhost', 10000, password='>$viK!uhVhx9PB8Ss')
g_i.gotostructures()
x_min = -10x_max = 10y_min = -10y_max = 10
boundaries =[]boundaries.append([x_min,y_min])boundaries.append([x_max,y_min])boundaries.append([x_max,y_max])boundaries.append([x_min,y_max])
g_i.polygon(*boundaries)
The error is the following (line 17 is g.i.polygon(*boundaries))
File "testpython1.py", line 17, in <module> g.i.polygon(*boundaries)NameError: name 'g' is not defined
Thanks for any tips,
EDIT : I found the error. Syntax error.
Dear Tomasz,
Indeed you have a typo exactly in line 17 and you say g.ipolygon(*boundaries) while it should be g_i.polygon(*boundaries)
Python is very strict with typos and here the g is recognized first as a variable not defined as it is separated with a dot. Of course, you define the variable g_i above.
Note that there is documentation about every command that is available and some extra examples provided with our Scripting reference (in V20.04):
communities.bentley.com/.../scripting-reference-and-how-to-use-it
Hello Stefanos,
many thanks. I just sent a request through the service request manager concerning some Python code !