Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
PLAXIS | SOILVISION
  • Product Communities
  • More
PLAXIS | SOILVISION
PLAXIS | SOILVISION Wiki Soil layer material assignment using Python
    • Sign in
    • +Working from home with PLAXIS
    • Working from home with SOILVISION
    • -PLAXIS | SOILVISION Wiki
      • Geotechnical SELECT Entitlements [GSE]
      • -PLAXIS
        • PLAXIS CONNECT Edition and legacy versions
        • +License - PLAXIS
        • +PLAXIS Software downloads
        • +Release Notes PLAXIS 2D and PLAXIS 3D
        • +Manuals - PLAXIS
        • -API / Python scripting - PLAXIS
          • How to install additional Python modules in PLAXIS
          • Access to Staged Construction settings using Python
          • Automatic line cross-section chart generation using Python
          • Changing the material colour using Python scripting
          • Combined plate results in one chart using Python
          • Create custom connection with selection API
          • How to create a tunnel using Python
          • How to get a load - displacement curve using Scripting interface
          • Identify Python commands from Plaxis command line
          • Material lists in PLAXIS – Python
          • Output scripting example: create curve data
          • Output scripting example: get anchor force
          • Output scripting example: get heave of excavation bottom
          • Output scripting example: get maximum bending moment
          • Polycurves to Polygons in PLAXIS 2D using Python
          • Receive instant notifications for finished calculations on your phone
          • Retrieve coordinates of a Polygon in PLAXIS 2D using Python
          • Retrieving soil layer info from boreholes using Python
          • Scripting reference and how to use it
          • Selection API for PLAXIS Input
          • Soil layer material assignment using Python
          • Tunnel advancement script for PLAXIS 3D
          • User defined Python script (3D): Extract displacements by coordinates
          • Adding functionality to PLAXIS Calculation Manager: pre- and post-processing
          • Remove invalid custom connections for PLAXIS 3D
        • +Downloads - PLAXIS
        • +Known issues - PLAXIS
        • +Models - PLAXIS
        • +Publications
        • +Tips and Tricks
        • +Tutorials - PLAXIS
        • +Verifications - PLAXIS
        • +Videos - PLAXIS
      • +PLAXIS MoDeTo
      • +SOILVISION
      • +Subscription Entitlement Service

     
     Questions about this article, topic, or product? Click here. 

    Soil layer material assignment using Python

    Application PLAXIS 2D
    PLAXIS 3D
    Version PLAXIS 2D 2017
    PLAXIS 3D 2016
    Date created 21 August 2017
    Date modified 21 August 2017

    When using boreholes in PLAXIS to define soil layers, Plaxis automatically creates soil polygons (2D) and soil volumes (3D) for these soil layers. When assigning materials to these soils, normally you would use a command in PLAXIS 2D like this:

    Plaxis command
    setmaterial Polygon_1.Soil Sand
    Python equivalent
    g_i.setmaterial(g_i.Polygon_1.Soil, g_i.Sand)
    

    or

    Plaxis command
    set Polygon_1.Soil.Material Sand
    Python equivalent
    g_i.Polygon_1.Soil.Material = g_i.Sand
    

    However, any soil layer might consist of any number of soil polygons, depending on the soil layer configuration (e.g. when a soil layer has zero thickness).
    For this, you can also assign the material to the Soillayer objects. The Soillayers object is a listable that is updated after any change to the borehole soil layer settings and lists the Soillayer objects top-down.

    Soil layer configuration in borehole

    0010> echo Soillayers
        SoilLayerList named "Soillayers"
        Count: 5
        0/-5. Soillayer named "Soillayer_1"
        1/-4. Soillayer named "Soillayer_2"
        2/-3. Soillayer named "Soillayer_3"
        3/-2. Soillayer named "Soillayer_4"
        4/-1. Soillayer named "Soillayer_5"
        

    To assign a new material to a newly added soil layer (not an inserted soil layer) you can use:

    Plaxis command
    setmaterial Soillayers[-1] Sand
    Python equivalent
    g_i.setmaterial(g_i.Soillayers[-1], g_i.Sand)
    

    For more complex geometries, you can for example do this:

    1. Create a borehole
    2. Add all soil layers
    3. Then assign soil materials to each layer top-down

    Example commands in PLAXIS 2D

    borehole 0
    soillayer 1  # add a soil layer with 1 m thickness 
    soillayer 1
    soillayer 1
    soillayer 1
    soillayer 1
    set Soillayer_1.Soil.Material SoilMat_1  # assign material to the top soil layer 
    set Soillayer_2.Soil.Material SoilMat_2  # assign material to the second layer 
    set Soillayer_3.Soil.Material SoilMat_3  # assign material to the third layer 
    set Soillayer_4.Soil.Material SoilMat_4  # assign material to the fourth layer 
    set Soillayer_5.Soil.Material SoilMat_5  # assign material to the fifth and final layer 

    Python solution

    g_i.borehole(0)
    # add soil layers, each 1 m thick:
    g_i.soillayer(1)
    g_i.soillayer(1)
    g_i.soillayer(1)
    g_i.soillayer(1)
    g_i.soillayer(1)
    # assign materials to the current configured soil layers
    g_i.Soillayers[0].Soil.Material = g_i.SoilMat_1
    g_i.Soillayers[1].Soil.Material = g_i.SoilMat_2
    g_i.Soillayers[2].Soil.Material = g_i.SoilMat_3
    g_i.Soillayers[3].Soil.Material = g_i.SoilMat_4
    g_i.Soillayers[4].Soil.Material = g_i.SoilMat_5
    

    This Python script can also be nicely written as:

    g_i.borehole(0)
    # add soil layers, each 1 m thick:
    for i in range(5):
         g_i.soillayer(1)
    # material list:
    materials = [g_i.SoilMat_1, 
                 g_i.SoilMat_2,
                 g_i.SoilMat_3,
                 g_i.SoilMat_4,
                 g_i.SoilMat_5]
    # assign materials to the current configured soil layers
    for layer, material in zip(g_i.Soillayers, materials):
        layer.Soil.Material = material
    

    Version

    The above examples are made with PLAXIS 2D 2017.00 using Python 3.4.x.

    See also

    Using PLAXIS Remote scripting with the Python wrapper

    [Tips and Tricks]


    Identify Python commands from Plaxis command line

    [Python Scripts]


    Plaxis Soil model numbers in command line

    [Tips and Tricks]


    Retrieving soil layer info from boreholes using Python

    [Python Scripts]


    Access to Staged Construction settings using Python

    [Python Scripts]

    • Plaxis 3D
    • python
    • API
    • py cookbook
    • soil layers
    • materials
    • Automation
    • Scripting
    • PLAXIS
    • Remote scripting
    • cookbook
    • python cookbook
    • soil layer
    • PLAXIS 2D
    • Share
    • History
    • More
    • Cancel
    • Micha van der Sloot Created by Bentley Colleague Micha van der Sloot
    • When: Wed, Dec 18 2019 9:33 AM
    • Stefanos Papavasileiou Last revision by Bentley Colleague Stefanos Papavasileiou
    • When: Tue, Oct 13 2020 6:20 AM
    • Revisions: 3
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies