Python API Oasys.PRIMER documentation

The Oasys.PRIMER package allows Python scripts to control the Oasys LS-DYNA Environment software PRIMER.

For full information and examples of the Python API visit: https://help.oasys-software.com/articles/py_api-21-0

Basic Information

The module uses gRPC to communicate with the PRIMER executable using the Oasys.gRPC module.

Connection methods

start(abspath, args=None, port=50051, memory=25, license=None, debug=False, batch=False, wait=5)

Start an instance of PRIMER on this machine.

Parameters:
  • abspath (string) – The absolute pathname of the PRIMER executable

  • args (list) – Optional. Any extra arguments to pass onto PRIMER

  • port (integer) – Optional. The gRPC port number used to communicate with PRIMER

  • memory (integer) – Optional. The memory allocated for scripts in PRIMER

  • license (string) – Optional. The location of the license file or server for PRIMER

  • debug (boolean) – Optional. Output debugging messages

  • batch (boolean) – Optional. If PRIMER should be started in batch mode without any main window

  • wait (integer) – Optional. Time to wait (in seconds) for PRIMER to start
    Added in version 21.0.1

Returns:

Connection object used to interact with PRIMER

Return type:

Connection

Example

To start PRIMER (installed at C:\Oasys 21\primer21_x64.exe):

import Oasys.PRIMER
connection = Oasys.PRIMER.start(abspath="C:\\Oasys 21\\primer21_x64.exe")
connect(port=50051, memory=25, hostname='localhost', debug=False)

Connect to an instance of PRIMER that is running.

Parameters:
  • port (integer) – Optional. The gRPC port number used to communicate with PRIMER

  • memory (integer) – Optional. The memory allocated for scripts in PRIMER

  • hostname (string) – Optional. The hostname of the machine that PRIMER is running on

  • debug (boolean) – Optional. Output debugging messages

Returns:

Connection object used to interact with PRIMER

Return type:

Connection

Example

To connect to an instance of PRIMER that is listening for gRPC messages on port 50051:

import Oasys.PRIMER
connection = Oasys.PRIMER.connect(port=50051)
disconnect(connection)

Disconnect from the instance of PRIMER that we are connected to and leave PRIMER running.

Example

To disconnect from PRIMER:

Oasys.PRIMER.disconnect(connection)
terminate(connection)

Terminate the instance of PRIMER that we are connected to, closing PRIMER.

Example

To terminate PRIMER:

Oasys.PRIMER.terminate(connection)

Indices and tables