Automation of Optislang using pyOptislang



I am trying to automate the running of Optislang file from the python environment using the pyOptislang.

My requirement is as follows

  1. Create an Optislang instance in python environment.
  2. Call and Run the Optislang file from the python environment.

I went through the user guide and the documentation from Ansys but not able to find the right documentation for this.

I tried modifying the existing scripts but I am getting errors.

So can you please support me by providing any example scripts for this requirement.


  • Daniel Arnold
    Daniel Arnold Member, Employee Posts: 9
    Name Dropper First Comment First Anniversary Ansys Employee

    Hi @Bharathk,

    thanks for reaching out to the forum.

    First I want to point to the PyOptiSLang documentation
    Herein you will find the Getting Started and the User Guide.

    As very simple example to create and run an optiSLang instance is:

    from ansys.optislang.core import Optislang
    osl = Optislang()
    osl_version = osl.osl_version_string

    sometimes the subsequent optiSLang process needs a bit more time due to license acquisitions so that you might increase the initial timeout of default 20s to a larger time span ini_timeout=60:

    from ansys.optislang.core import Optislang
    osl = Optislang(ini_timeout=60)
    osl_version = osl.osl_version_string

    To run a optiSLang project by the pythonic interface you'll need to open the project and start it:

    from ansys.optislang.core import Optislang
    from ansys.optislang.core import examples
    project_path = examples.get_files("simple_calculator")[1][0]
    with Optislang(project_path=project_path) as osl:

    Please reply your results or findings here.