Create custom connection with selection API

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.

Related posts

Privacy Preference Center

Necessary

The Cookies are necessary for the site to function

CONSENT, NID, _cfduid, wp-settings-time-16, wp-setting-16, wordpress_test_cookie, gdpr[allowed_cookies], gdpr[consent_types], wp_woocommerce_session, wordpress_logged_in, wordpress_sec, PHPSESSID

Advertising

These Cookies are used to provide you with useful information based on recent browser data

_gads
UserMatchHistory, lang, BizoID
IDE
fr
NID
lidc, bcookie

Analytics

These are used to track user interaction and detect potential problems. These help us improve our services by providing analytical data on how users use this site

_ga, _gid

Other