Plaxis not starting remotly

Hello,

I have prepared a Python script to accelerate routinely calculation in Plaxis. I would like it to open Plaxis and start executing the actions I have set in the script withou me having to open Plaxis, close the stat window and set the server manually. My scritp instructs Plaxis to open remotelly however, the stating window and a 'non-active server' prevent the scritp from seting boreholes, geometry, mesh... and so on.

1) Are there any Python codding lines that would allow to close the start window?

2) Is there a way to 'Configure remote scripting server...' using Python?

 

  • It is possible to start PLAXIS Input with specifying the port number and the password. So if you launch PLAXIS via the command line (or the Python subprocess module)

    When using the remote scripting in an automated process, you can start the server without manual interaction by launching your PLAXIS application with the AppServerPort and ApppServerPassword command line parameters.

    For example in order to start the server in PLAXIS 2D on port 21403 using mypassword as the password:

    C:\Program Files\Bentley\Geotechnical\PLAXIS 2D CONNECT Edition V20\PLAXIS2Dx.exe --AppServerPassword=mypassword --AppServerPort=21403
  • Hi Micha,

    Part of the porblem is solved with the line you suggested. I used the following lines in my Python script to start Plaxis remotly with password and port number (just as an example for very unexperienced users of Python as me).

    import os

    os.system('cmd /k "C:\Program Files\Bentley\Geotechnical\PLAXIS 2D CONNECT Edition V20\Plaxis2DXInput.exe" --AppServerPassword=xxxxxxxxxxxxxxxx --AppServerPort=10000')

    s_i.new()

    Although Plaxis starts, with the remote script configuration already set, it does not move out of the first empty window (see attached figure).  There is no error message returned in the Python command window.

    To get out of the Plaxis empty window I have to manually clik 'new button' but, other scripts that I prepared to build a Plaxis model do not run.

    I still have to manually open Plaxis and set the remote server connection manually and, only after that, I can run the Python scripts I have prepared.

    Do you have any suggestion to sort this problem?

    All the best,

    Joao

  • Hi Joao,

    In this case, it would be best to use the subprocess module.
    Also, it helps to add a small timeout for PLAXIS to launch and fetch the input server and global objects (s_i, g_i)

    This works for me:

    import subprocess
    import os
    from plxscripting.easy import *
    
    inputport = 10000
    plaxispw= r'YOURPASSWORD'
    plaxis_path = r'C:\Program Files\Bentley\Geotechnical\PLAXIS 2D CONNECT Edition V20'
    plaxis_input = 'PLAXIS2DxInput.exe'
    
    # first launch PLAXIS
    args = [os.path.join(plaxis_path, plaxis_input),
            "--AppServerPort={}".format(inputport),
            "--AppServerPassWord={}".format(plaxispw)]
    inputprocess = subprocess.Popen(args)
    
    # then initialize the new_server with additional waiting time
    # due to startup of PLAXIS
    s_i, g_i = new_server('localhost', inputport, password=plaxispw, timeout=10.0)
    s_i.new()
    
    ... add your code here
    
    

    If you want to open a second instance after this code is done and  closing PLAXIS, you can add this to the code to make sure PLAXIS Input is stopped:

    ## and to make sure PLAXIS is closed after the run:
    ## Popen process .terminate()  this is a hard stop! nice closure of the project is recommended
    s_i.close()
    inputprocess.terminate()
    

    Alternatively, you can check if you opened PLAXIS already, and reuse the existing running PLAXIS application.

    Resources for Python/s subprocess module: https://docs.python.org/3.7/library/subprocess.html 

    Answer Verified By: Joao Ferreira Verde 

  • Micha,

    Thank you. The code works well for me too.

    Best regards,

    Joao

  • Hello, sorry this code does not work for me, because it indicates -> ModuleNotFoundError: No module named 'plxscripting'