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

Daniel Arnold
Daniel Arnold Member, Employee Posts: 13
Second Anniversary Name Dropper First Comment Ansys Employee
✭✭✭

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: 13
    Second Anniversary Name Dropper First Comment Ansys Employee
    ✭✭✭
    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)