1. 引言
在过去,《计算岩土力学》一直使用Spyder编辑和运行Plaixs【Plaxis使用Spyder替换默认编辑器SciTE的方法】,如在【VS Code运行Anaconda虚拟环境下的代码】所示,我们正在把各种应用代码的IDE逐渐转移到VS Code。本文描述了设置Plaxis Python的过程。
2. 连接
基本思路与前述设置相同,即要连接上能运行Plaxis的Pyhon解释器,在默认的搜索框中(Ctrl+Shift+P键)不包括Plaxis的Pyhton,因而需要使用"Enter interpreter path..."指定,找到Plaxis下python.exe的位置选择即可。
E:\05_Plaxis\VSCodeTest>"c:/ProgramData/Seequent/PLAXIS Python Distribution V2/python/Scripts/activate.bat"
(PLAXIS) E:\05_Plaxis\VSCodeTest>
3. 测试
line1_g = g_i.line((0, 0), (3, 0))[-1]
line2_g = g_i.line((5, 0), (5, 5))[-1]
line3_g = g_i.line((0, 8), (3, 4))[-1]
beam1_g = g_i.plate(line1_g)
beam2_g = g_i.plate(line2_g)
lines = [b.Parent for b in g_i.Plates]
print(g_i.delete(*lines))
(2) 创建plate单元
g_i.gotostructures()
material=['Concrete']
first_point=[-10,0]
second_point=[10,0]
for i in range(len(material)):
g_i.platemat('Identification',material[i])
platematerials = [mat for mat in g_i.Materials[:] if mat.TypeName.value == 'PlateMat']
plate=g_i.plate(
(first_point[0],first_point[1]),
(second_point[0],second_point[1]),
)
plate1=plate[-1]
plate2=plate[-2]
g_i.posinterface(plate2)
g_i.neginterface(plate2)
plate1.setmaterial(platematerials[0])