PyOptiSLang: Ansys Workbench integration: Register all project parameter and responses

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

How can I
1. add an Ansys Workbench integration node to the Ansys optiSLang project
2. register defined parameter and responses

Best Answer

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

    That's possible in few easy steps:

    1. Import modules
    from ansys.optislang.core import Optislang
    from ansys.optislang.core.nodes import IntegrationNode, DesignFlow
    import ansys.optislang.core.node_types as node_types
    
    1. create Ansys optiSLang class object
    osl = Optislang(ini_timeout=240)
    
    1. create Ansys Workbench integration node
    root_system = osl.application.project.root_system
    wb_node: IntegrationNode = root_system.create_node(
        name='WB',
        type_=node_types.awb2_plugin,
        design_flow=DesignFlow.RECEIVE_SEND
    )
    
    wb_node.set_property(
        name="WorkbenchProjectFile",
        value={
            "path": {
                "base_path_mode": {"value": "ABSOLUTE_PATH"},
                "split_path": {"head": "", "tail": "coupled_function.wbpz"},
            }
        },
    )
    

    Example can be found at Coupled Function optiSLang Tutorial example
    4. register parameter and responses

    wb_node.load()
    wb_node.register_locations_as_parameter()
    wb_node.register_locations_as_response()
    
    1. run project
    osl.application.project.start(wait_for_finished=True)
    

Answers

  • Leire
    Leire Member Posts: 1
    First Comment
    **

    In relation to this discussion, I’d like to know where I can find a list of the adjustable properties of each node type. In my case, I want to edit the run options inside the wb_node. I’ve done it in optiSLang, and now I want to be able to do it in PyOptiSLang.

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

    Hi @Leire,

    there are basically two ways of getting those information:
    1. you can extract the json object with python_node.get_properties()
    2. open your created project with Ansys optiSLang GUI and open Project overview: