This tutorial demonstrates controlling PLAXIS 2D with Python via the
Remote Scripting API, using a Jupyter-like step-by-step flow converted into a clean web page.
The scripting objects exposed by PLAXIS are:
s_i – Input server object (sends commands to PLAXIS Input).
g_i – Global Input object (materials, geometry, boreholes, mesh, etc.).
s_o and g_o – corresponding Output objects for post-processing.
Switch to Structures, define the embankment polygon, and assign embankment sand.
# Go to Structures mode
g_i.gotostructures()
# Embankment polygon and material assignment
embankment_polygon = g_i.polygon((14,0), (22,4), (24,4), (36,0))[0]
embankment_polygon.Soil.setproperties("Material", embankment_sand)
8️⃣ Mesh Generation & Monitoring Points
Generate a fine mesh and add a curve point near the slope toe in Output for displacement tracking.
# Mesh
g_i.gotomesh()
g_i.mesh(0.04) # target element size
# Monitoring point in Output
g_i.selectmeshpoints()
g_o.addcurvepoint('node', g_o.Soil_1_1, (18, 0))
g_o.update()
9️⃣ Phases & Calculation
Create staged construction phases, activate the embankment, and run calculations.
# Staged Construction
g_i.gotostages()
phase0_s = g_i.InitialPhase
# New phases (drained and undrained scenarios)
phase1_s = g_i.phase(phase0_s)
phase2_s = g_i.phase(phase0_s)
# Re-acquire the polygon handle in Stages
embankment_g = g_i.Polygons[0]
embankment_g.activate(phase1_s, phase2_s)
# Switch subgrade to undrained for phase 2
g_i.Soils[1].Material.set(phase2_s, subgrade_clay_undrained)
# Run calculation and save
g_i.calculate()
g_i.save(filepath)
🔟 Factor of Safety (Phi–c reduction)
Clone phases and set DeformCalcType to safety for drained and undrained cases.
# Create FoS phases
phase3_s = g_i.phase(phase1_s) # drained base
phase4_s = g_i.phase(phase2_s) # undrained base
# Identify and set to Safety
phase3_s.Identification = "FoS of drained case"
phase3_s.DeformCalcType = "safety"
phase4_s.Identification = "FoS of undrained case"
phase4_s.DeformCalcType = "safety"
# Calculate both
g_i.calculate()
1️⃣1️⃣ Extracting Results
View a phase, map to Output, and query vertical displacement at the curve point.
# Link a Stages phase to Output
g_i.view(phase2_s)
phase2_o = get_equivalent(phase2_s, g_o)
# Last curve point (added earlier)
curvepoint_o = g_o.CurvePoints.Nodes[-1]
# Vertical displacement at the point
uy_o = g_o.getcurveresults(curvepoint_o, phase2_o, g_o.ResultTypes.Soil.Uy)
print(uy_o)
# Explore other result types (interactive inspection)
# dir(g_o.ResultTypes.Soil)
Use Output’s plot tools for contours and vectors; the API enables scripted extraction for reports.
1️⃣2️⃣ Summary
Connected to PLAXIS servers and saved a new project.
Configured project type and domain; set borehole, layer, and groundwater head.
Defined hardening soil materials (drained vs. undrained) and assigned subgrade/embankment.
Generated a fine mesh and added an Output monitoring point.
Created staged phases, ran calculations, and performed Phi–c reduction safety analysis.
Queried Output results (e.g., settlement at a curve point).
Next-step ideas
Automate parametric material sweeps for sensitivity and FoS envelopes.
Batch-export safety factors and displacements into CSV for dashboards.