Skip to main content

Python API for Oasys T/HIS

Project description

The Oasys.THIS package allows Python scripts to control the Oasys LS-DYNA Environment software T/HIS.

Basic Information

The module uses gRPC to communicate with the T/HIS executable using the Oasys.gRPC module.

The Python API is currently in Beta testing for version 21.0. If you would like to be involved in testing it then please contact dyna.support@arup.com.

Getting started

As python is running outside T/HIS, the first thing a script needs to do is to either start an instance of T/HIS, or to connect to an already running instance of T/HIS. At the end of the script you should then either disconnect again or terminate the T/HIS instance.

A skeleton python script to start T/HIS (Installed at C:\Oasys 21\this21_x64.exe) and then terminate it is:

import Oasys.THIS

connection = Oasys.THIS.start(abspath="C:\\Oasys 21\\this21_x64.exe")

...

Oasys.THIS.terminate(connection)

By default T/HIS will use port 50052 to communicate with Python and will allocate 25Mb of memory for running scripts. These can be changed by adding port and memory arguments to the start function. e.g:

connection = Oasys.THIS.start(abspath="C:\\Oasys 21\\this21_x64.exe", port=1234, memory=100)

T/HIS can also be started in batch mode so that the main graphics window is not shown by using a batch argument:

connection = Oasys.THIS.start(abspath="C:\\Oasys 21\\this21_x64.exe", batch=True)

To connect to an instance of T/HIS that is already running, T/HIS must currently have been started in a special mode telling it to listen on a port for gRPC messages. This is done by using the -grpc command line argument when starting T/HIS. e.g:

'C:\\Oasys 21\\this21_x64.exe' -grpc=50052

A skeleton script to connect to T/HIS and disconnect again would then be:

import Oasys.THIS

connection = Oasys.THIS.connect(port=50052)

...

Oasys.THIS.disconnect(connection)

or if you want to terminate the instance of T/HIS use terminate instead of disconnect.

Python API

The JS API has been available for several years, is stable and works well, so we have designed the Python API to have the same classes, methods and properties as the JS API. The Python API is currently in beta release and does not yet have any documentation, so for information on the available classes etc please see the Oasys JS API documentation.

However, the following classes are not available:

  • PopupWindow (GUIs not available from Python)

  • Widget (GUIs not available from Python)

  • WidgetItem (GUIs not available from Python)

  • File (use Python i/o instead)

  • Ssh (use python modules instead)

  • XlsxWorkbook (use python modules instead)

  • XlsxWorksheet (use python modules instead)

  • XMLParser (use python modules instead)

  • Zip (use python modules instead)

If an argument in the JS API is an object then the equivalent in Python will be a dict, and if an array in JS, the equivalent in Python will be a list.

Simple Example

It’s probably easier to give a simple example of how to do something in T/HIS using Python compared to JavaScript, so here is simple example that opens some results and plots kinetic energy for a part using the JS API:

var m = Model.Read("C:\\work\\test\\example.thf");

var flag = AllocateFlag();
ClearFlag(flag);

m.SetFlag(flag, Entity.PART, -300000);

var curves = m.GetDataFlagged(flag, Component.GKE);

Plot();

and here is the equivalent example in Python:

import Oasys.THIS

connection = Oasys.THIS.start(abspath="C:\\oasys 21\\this21_x64.exe")

m = Oasys.THIS.Model.Read("C:\\work\\test\\example.thf")

flag = Oasys.THIS.AllocateFlag()
Oasys.THIS.ClearFlag(flag)

m.SetFlag(flag, Oasys.THIS.Entity.PART, -300000)

curves = m.GetDataFlagged(flag, Oasys.THIS.Component.GKE)

Oasys.THIS.Plot()

Oasys.THIS.disconnect(connection)

More Information

For more details on the Oasys LS-DYNA environment software please see

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Oasys.THIS-21.0.0b9.tar.gz (34.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

Oasys.THIS-21.0.0b9-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file Oasys.THIS-21.0.0b9.tar.gz.

File metadata

  • Download URL: Oasys.THIS-21.0.0b9.tar.gz
  • Upload date:
  • Size: 34.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for Oasys.THIS-21.0.0b9.tar.gz
Algorithm Hash digest
SHA256 d86ec11e5e32a857c8b398cee95c0784efae202b3290c68d19accab5194aeafe
MD5 74d3b4c6ae44abead520bb81aecb8d64
BLAKE2b-256 c7489a7e4809aef01ccbc33b443d538054a2a6d9ac1229458e6c3fb012be1b4a

See more details on using hashes here.

File details

Details for the file Oasys.THIS-21.0.0b9-py3-none-any.whl.

File metadata

  • Download URL: Oasys.THIS-21.0.0b9-py3-none-any.whl
  • Upload date:
  • Size: 43.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.4

File hashes

Hashes for Oasys.THIS-21.0.0b9-py3-none-any.whl
Algorithm Hash digest
SHA256 a085d5ef001fa7638e440ed2fe4738b9e003c8a3f291d52e3897aa40c2c2bd47
MD5 e6b31daabd587eddc30e80faf1e33e7d
BLAKE2b-256 0ab0e472d19fecd18614165457b04ee4e6469bfe3ded3299e1a47c1041038877

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page