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 Create custom connection with selection API
    • Sign in
    • +Working from home with PLAXIS
    • +Working from home with PLAXIS LE
    • -PLAXIS 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
          • Automatically generated cross-sections of embankments
        • +Downloads - PLAXIS
        • +Known issues - PLAXIS
        • +Models - PLAXIS
        • +Publications
        • +Tips and Tricks
        • +Tutorials - PLAXIS
        • +Verifications - PLAXIS
        • +Videos - PLAXIS
      • +PLAXIS LE
      • +PLAXIS Monopile Designer
      • +SOILVISION
      • +Subscription Entitlement Service

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

    Create custom connection with selection API

    Application PLAXIS 3D
    Version PLAXIS 3D 2018
    Date created 27 June 2019
    Date modified 27 June 2019

    In order to create a custom connection in PLAXIS 3D Input program the following steps are needed (see also video):

    1. Select a beam or a plate
    2. Holding Ctrl+LMB multi-select the connecting plate (LMB=left-mouse button)
    3. RMB to open the popup window with options (RMB=right-mouse button)
    4. Select the option: Create a custom connection

    Note that a custom connection is possible between two plates and between a beam and a plate. For more information please check our Reference manual.

    The above procedure is easy and straightforward when only a few custom connections are to be defined. However, when many connections are to be created this starts becoming cumbersome (see attached video: Create custom connection with PLAXIS GUI).

    With the selection API, this can be done even faster by directly clicking on the objects of interest one after the other and the Python script will do the rest (see attached video: Create custom connection with PLAXIS Python selection API):

    from plxscripting.plx_scripting_exceptions import PlxScriptingError 
    
    print('Python script running...') 
    
    while True: 
        sel_objs = g_i.selection[:] 
        if not sel_objs: 
                pass  # nothing selected 
        else: 
            if len(sel_objs) == 2: 
                try: 
                    g_i.connection(*sel_objs) 
                    g_i.selection = []  # empty the selection 
                except PlxScriptingError: 
                    print('Connection already exists. Choose next objects or quit.') 
                    g_i.selection = []  # empty the selection                         
                    pass  # command failed so back to the while-loop 
             else: 
                pass  # continue the while-loop until two items are selected
    

    Conditions

    The following should be considered about the code above:

    • The script requires the existence of plates
    • The code will run forever unless it is manually stopped due to the while-loop. The advantage of this while-loop, in this case, is that you can just let the script run while you conveniently just select all the connection parts without interruption.
    • The code covers the cases that:
      • No selection was made
      • Only a selection of exactly 2 objects can occur to make the custom connection
      • A custom connection already exists using a try-except statement
    • The PlxScriptingError is the class that covers the different errors that can occur when using the Plaxis command line.
    • To see all prerequisites, please refer to this article: Using PLAXIS Remote scripting with the Python wrapper

    Usage instructions for Python script 

    To use this Python script: 

    • Download the file (use Save As...) 
    • Launch PLAXIS Input with a project with plates 
    • Make sure you are in Staged construction mode 
    • Open SciTE under Expert > Python > Editor... 
    • Open the custom_connection_selection_API.py file  
    • Select Tools > Go (or keyboard key F5) 
    • The Python script is running... Select two plates to make a custom connection. 
    • When finished select Tools > Stop executing (or keyboard keys Ctrl + Break) 

    Alternatively, the Python script can be run from the dedicated folder for Python tools in the installation directory. By default, this is at:
    C:\Program Files\Bentley\Geotechnical\PLAXIS 3D CONNECT Edition V20\pytools\input
    For older versions, this is:
    C:\Program Files\Plaxis\Plaxis 3D\pytools\input
    The Python script can then be found in PLAXIS Input Expert menu, under Python > Run Python tool.

    Note that for this approach the boilerplate needs to be adjusted to:
    s_i, g_i = new_server()

    Version

    The script is tested with PLAXIS 3D 2018.01 and Python 3.4 using Tutorial 2 - Excavation in sand from the Plaxis Tutorial Manual.

    Downloads

    • [Video] Create custom connection with PLAXIS GUI
    • [Video] Create custom connection with PLAXIS Python selection API
    • [Python script] Create custom connection with selection API

    See also

    Selection API for PLAXIS Input

    [Python Scripts]

    • Plaxis 3D
    • python
    • API
    • py cookbook
    • Input
    • Automation
    • Scripting
    • PLAXIS
    • Remote scripting
    • cookbook
    • selection
    • python cookbook
    • pyapp
    • Share
    • History
    • More
    • Cancel
    • Micha van der Sloot Created by Bentley Colleague Micha van der Sloot
    • When: Wed, Dec 18 2019 9:35 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