The following article gives information on how to use the Remote scripting feature to create a tunnel using the PLAXIS tunnel designer.In this example, we will show the Python commands to generate the tunnel cross-section in both PLAXIS 2D and PLAXIS 3D, based on the geometry of the PLAXIS 2D Tutorial Lesson - Excavation of a NATM tunnel [link].
The PLAXIS 2D geometry of the NATM tunnel in the tutorial lesson
To better understand the structure of the commands used in the example, some are explained below:
set Tunnel_1.CrossSection.Segments[0].ArcProperties.Radius 10.4
With Python, the set command can be written using the assignment statement set command(name = expression):
g_i.Tunnel_1.CrossSection.Segments[1].ArcProperties.Radius = 10.4
add Tunnel_1.CrossSection
With Python, the command can be written in the following way:
g_i.Tunnel_1.CrossSection.add()
Note that the empty field in the parentheses indicates that there are no parameters defined for this method (command).
# define the tunnel and assign a variable to it tunnel = g_i.tunnel(0, 16) # first segment defined command by command tunnel.CrossSection.add() tunnel.CrossSection.Segments[-1].SegmentType = "Arc" tunnel.CrossSection.Segments[-1].ArcProperties.Radius = 10.4 tunnel.CrossSection.Segments[-1].ArcProperties.CentralAngle = 22 # function for the rest of segments def add_arc(tunnel, radius, angle): segment = tunnel.CrossSection.add() segment.SegmentType = "Arc" segment.ArcProperties.Radius = radius segment.ArcProperties.CentralAngle = angle # call the function to create two more segments add_arc(g_i.Tunnels[-1], 2.4, 47) add_arc(g_i.Tunnels[-1], 5.8, 50) # extend to symmetry axis and symmetrically close the shape tunnel.CrossSection.extendtosymmetryaxis() tunnel.CrossSection.symmetricclose() # add subsections subsection, subsection_segment = tunnel.CrossSection.addsubcurve() subsection.Offset2 = 3 subsection_segment.SegmentType = "Arc" subsection_segment.ArcProperties.Radius = 11 subsection_segment.ArcProperties.CentralAngle = 360 # create a list for all segments and subsections that will be intersected segments_subsections = [] for subsection in tunnel.CrossSection.Subsections[:]: segments_subsections.append(subsection) for segment in tunnel.CrossSection.Segments[:]: segments_subsections.append(segment) # intersect the created list and delete the odd one tunnel.CrossSection.intersectsegments(*segments_subsections) tunnel.CrossSection.delete(tunnel.CrossSection.Subsections[2]) # define plates for slice polycurves, assign material, create negative interface for tunnel_slice in tunnel.SliceSegments[:]: g_i.plate(tunnel_slice) # next command requires a material to be predefined for the lining tunnel_slice.Plate.Material = g_i.Lining if tunnel_slice == tunnel.SliceSegments[4] or tunnel_slice == tunnel.SliceSegments[5]: pass else: g_i.neginterface(tunnel_slice) # generate the tunnel g_i.generatetunnel(tunnel)
# define the tunnel and assign a variable to it tunnel = g_i.tunnel(0, 0, 0, 1, 0, 0, 0, 0, 1) # first segment defined command by command tunnel.CrossSection.add() tunnel.CrossSection.Segments[-1].SegmentType = "Arc" tunnel.CrossSection.Segments[-1].ArcProperties.Radius = 10.4 tunnel.CrossSection.Segments[-1].ArcProperties.CentralAngle = 22 # function for the rest of segments def add_arc(tunnel, radius, angle): segment = tunnel.CrossSection.add() segment.SegmentType = "Arc" segment.ArcProperties.Radius = radius segment.ArcProperties.CentralAngle = angle # call the function to create two more segments add_arc(g_i.Tunnels[-1], 2.4, 47) add_arc(g_i.Tunnels[-1], 5.8, 50) # extend to symmetry axis and symmetrically close the shape tunnel.CrossSection.extendtosymmetryaxis() tunnel.CrossSection.symmetricclose() # add subsections subsection, subsection_segment = tunnel.CrossSection.addsubcurve() subsection.Offset2 = 3 subsection_segment.SegmentType = "Arc" subsection_segment.ArcProperties.Radius = 11 subsection_segment.ArcProperties.CentralAngle = 360 # create a list for all segments and subsections that will be intersected segments_subsections = [] for subsection in tunnel.CrossSection.Subsections[:]: segments_subsections.append(subsection) for segment in tunnel.CrossSection.Segments[:]: segments_subsections.append(segment) # intersect the created list and delete the odd one tunnel.CrossSection.intersectsegments(*segments_subsections) tunnel.CrossSection.delete(tunnel.CrossSection.Subsections[2]) # define plates for slice surfaces, assign material, create negative interface for tunnel_slice in tunnel.SliceSurfaces[:]: g_i.plate(tunnel_slice) # next command requires a material to be predefined for the lining tunnel_slice.Plate.Material = g_i.Lining if tunnel_slice == tunnel.SliceSurfaces[4] or tunnel_slice == tunnel.SliceSurfaces[5]: pass else: g_i.neginterface(tunnel_slice)
# define a trajectory for the tunnel tunnel.Trajectory.add()
tunnel.Trajectory.Segments[0].LineProperties.Length = 12
# generate the tunnel
tunnel.regeneratetunnelphases()
g_i.generatetunnel(tunnel)
The goal of this example is to show how to use Python to create a tunnel in PLAXIS 2D and PLAXIS 3D: its focus is on geometry creation. To run this script, a plate material (named Lining) already needs to be defined in the current project.