Python node and help#

This example demonstrates how to create workflow components and configure them.

It uses the file to create a Python2 node. and perform these tasks:

  • Adds some source code.

  • Adds and removes parameters and responses.

  • Adds internal variables.

It then uses the file to print which nodes are available in the Python console. Lastly, it explains how you can optionally save the project to a desired location.

Perform required imports#

Perform the required imports.

from ansys.optislang.core import Optislang
import ansys.optislang.core.examples as examples

Create optiSLang instance#

Create the optiSLang instance.

osl = Optislang(ini_timeout=60)

Get paths of example scripts and run them#

Get the paths of the example scripts and then run these scripts.

paths1 = examples.get_files("python_node")
paths2 = examples.get_files("python_help")

Optionally save project#

If you want to save the project to some desired location, uncomment and edit these lines:

path = r'<insert-desired-location>'
osl.application.save_as(os.path.join(path, "test_project.opf"))

Stop and cancel project#

Stop and cancel the project.


View generated workflow#

This image shows the generated workflow.

Result of script.

Gallery generated by Sphinx-Gallery