How can I set the script path of a PythonActor?

Daniel Arnold
Daniel Arnold Member, Employee Posts: 16
Second Anniversary 5 Likes Name Dropper First Comment
✭✭✭

I want to create an Ansys optiSLang project using optiSLang's python API.
In the project a python node should be added and the path to a script should be used.

How can I do that?

Tagged:

Best Answer

  • Daniel Arnold
    Daniel Arnold Member, Employee Posts: 16
    Second Anniversary 5 Likes Name Dropper First Comment
    ✭✭✭
    Answer ✓

    This can be done in few simple steps/lines:
    1. define a RelativeSplittedPath to the script:

    import stdcpp_python_export
    csv_path = r"c:\path\to\script.py"
    osl_csv_path = stdcpp_python_export.RelativeSplittedPath(csv_path, stdcpp_python_export.BasePathMode.PROJECT_RELATIVE)
    
    1. Add a PythonActor into the project:
    pyactor = actors.PythonActor("Python")
    add_actor(pyactor)
    
    1. Set the path property of the actor:
    pyactor.path = osl_csv_path
    

    further information can be found at: Ansys optiSLang Python API