Can we launch workbench through webapp using PyWB module.?
Options

Naveen Kumar Begari
Member Posts: 104
**
in Structures
A simple code with webapp, when we click a button, workbench should launch, but here i get an error. Could anyone try this code and confirm.?
import dash from dash import html, Output, Input from ansys.workbench.core import launch_workbench from ansys.mechanical.core import connect_to_mechanical , launch_mechanical import dash_bootstrap_components as dbc app = dash.Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP]) app.layout = dbc.Container([ html.H3("Launch ANSYS Workbench"), dbc.Button("Launch Workbench", id="launch-btn", color="primary", className="mt-2"), html.Div(id="status", className="mt-3") ]) @app.callback( Output("status", "children"), Input("launch-btn", "n_clicks"), prevent_initial_call=True ) def run_workbench(n): try: wb = launch_workbench() # m = launch_mechanical() return "Workbench launched successfully." except Exception as e: return f"Failed to launch Workbench: {str(e)}" if __name__ == "__main__": app.run(debug=True)
Tagged:
0
Answers
-
Hi @Naveen Kumar Begari I've had a go at this and I get the same error as you, although it looks like this might be a Dash/Flask issue rather than a PyWorkbench one as it seems something is going wrong in there according to the traceback. I've tried to find a solution but been unable.
0 -
Would someone in the @Structures-Scripting-Team have a better time with this?
0