Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
GeoStudio | PLAXIS
  • Product Communities
GeoStudio | PLAXIS
GeoStudio | PLAXIS Wiki How to identify the material name of an object in Output using Python scripting
    • Sign In
    • -Geotechnical Analysis Wiki
      • +GeoStudio
      • -PLAXIS
        • +Software and License - PLAXIS
        • +Documentation - PLAXIS
        • -API / Python scripting - PLAXIS
          • Access to Staged Construction settings using Python
          • Adding functionality to PLAXIS Calculation Manager: pre- and post-processing
          • Automatic line cross-section chart generation using Python
          • Automatically generated cross-sections of embankments
          • Changing the material colour using Python scripting
          • Combined plate results in one chart using Python
          • Create custom connection with selection API
          • Damage assessment of adjacent buildings caused by excavations using the Burland's chart
          • Export and format plots from PLAXIS Output using Python
          • How to create a tunnel using Python
          • How to get a load - displacement curve using Scripting interface
          • How to identify the material name of an object in Output using Python scripting
          • How to install additional Python modules in PLAXIS
          • How to open and close a PLAXIS project with Python
          • How to retrieve results from PLAXIS Output by the node number
          • Identify Python commands from Plaxis command line
          • Material lists in PLAXIS – Python
          • Material Property changes for Python scripting
          • Optimize excavation calculation time for wall horizontal displacement criteria
          • 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
          • Remove invalid custom connections for PLAXIS 3D
          • 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
          • Support capacity evaluation of a tunnel lining in PLAXIS 2D
          • Tunnel advancement script for PLAXIS 3D
          • User defined Python script (3D): Extract displacements by coordinates
        • +Known issues - PLAXIS
        • +Models - PLAXIS
        • +Tips and Tricks
        • +Publications
        • +Videos - PLAXIS
      • +PLAXIS Monopile Designer
      • +PLAXIS LE
      • +SOILVISION
      • +Geotechnical SELECT Entitlements [GSE]
      • +Subscription Entitlement Service

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

    How to identify the material name of an object in Output using Python scripting

    Application PLAXIS 2D
    PLAXIS 3D
    Version PLAXIS 2D 2023.2
    PLAXIS 3D 2023.2
    Date created 21 September 2023
    Date modified 21 September 2023
    Original author Stefanos Papavasileiou - Bentley Technical Support Group

    Description

    The PLAXIS Output program, apart from displaying calculation results of numerical analyses, also provides essential information on the model definition, such as assigned materials on soil/rock polygons or volumes as well as on structural elements, such as plates and embedded beams.

    It is common to have different materials assigned to different objects depending on the settings applied in each phase. This is specified in the Staged construction in the PLAXIS Input program.

    Figure 1. Example project and material shown for selected plate in Phase_7 (PLAXIS Input).

    Figure 2. Material sets shown in PLAXIS Output

    This article will show how to use the HTTP REST API / Remote Scripting feature to identify the material name used for plates in a particular phase.

    Note that in this code example, we will use a case based on the PLAXIS 2D Tutorial 06: Dry excavation using a tie back wall project to describe how to retrieve the information required.

    Python solution

    Workflow overview

    The PLAXIS Output material object contains a specific property to store the information on the material index shown in plots and tables. This depends on the material object itself, e.g., Soil, Plate, EmbeddedBeam, etc., and can be queried as:

    g_o.ResultTypes.Plate.MaterialIndex
    

    This property can be retrieved via the getresults command, which will return a list of material indices per element. Note that the “element” is a parameter of the getresults command; we can also query this per “node” and “stress point”. For example:

    materialIndices = g_o.getresults(phase, g_o.ResultTypes.Plate.MaterialIndex, 'element')
    

    The created list of material indices can now be queried to provide the .Identification property per element. The result can be another list, which will have the same order as the material index list (materialIndices) generated before.

    materialNames = [g_o.Materials[index].Identification.value for index in materialIndices]
    

    Since we want to show the material object for each plate, a separate list can be created for the plate .Name property:

    plateNames = [plate_part.Name.value for plates in g_o.Plates for plate_part in plates]
    

    Finally, the two created lists can be combined using Python’s zip() function, which can help print the contents side-by-side:

    for plate_names in zip(plateNames, materialNames):
        print('\t'.join(["{}".format(i) for i in plate_names]))
    

    Example with code

    In the following example, we will use the information learnt to collect the material information and retrieve it using a simple Python script.

    Let’s assume that in this project, a different plate material is assigned in the last phase of the project (Phase_7). Note that, generally, a Reduction of stiffness does not lead to a change in displacements.

    This Python script aims to retrieve the material identification for every plate in the last two phases (Phase_6 and Phase_7) of the calculated project.

    for phase in g_o.Phases[6:]: 
      plateNames = [plate_part.Name.value for plates in g_o.Plates for plate_part in plates] 
      materialIndices = g_o.getresults(phase, g_o.ResultTypes.Plate.MaterialIndex, 'element') 
      materialNames = [g_o.Materials[index].Identification.value for index in materialIndices] 
      print(phase.Name, "===========") 
     
      for plate_names in zip(plateNames, materialNames): 
        print('\t'.join(["{}".format(i) for i in plate_names]))
    

    Figure 3. Python script providing the material identification per plate object for the last two phases (PLAXIS Output)

    See also

    Obtaining tabulated data for materials in PLAXIS Input    [Tips and Tricks]


    Material lists in PLAXIS – Python    [API/Python scripting]

    • output
    • PLAXIS 3D
    • python
    • pytool
    • material set
    • Scripting
    • PLAXIS
    • Remote scripting
    • cookbook
    • material
    • PLAXIS 2D
    • Share
    • History
    • More
    • Cancel
    • Stefanos Papavasileiou Created by Bentley Colleague Stefanos Papavasileiou
    • When: Tue, Sep 19 2023 4:51 AM
    • Stefanos Papavasileiou Last revision by Bentley Colleague Stefanos Papavasileiou
    • When: Thu, Sep 21 2023 12:05 PM
    • Revisions: 2
    • 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

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