import gradio as gr from utils.ansys_utils import generate_apdl_script, run_simulation from utils.gcode_utils import generate_gcode def automate_workflow(dimensions, material, analysis_type, tolerances, forces, acoustic_properties): """ Automates the workflow: 1. Generates APDL scripts based on input parameters. 2. Runs the simulation (structural, thermal, or acoustic). 3. Generates G-Code for CNC machining (optional). """ # Step 1: Generate APDL script based on the parameters apdl_script = generate_apdl_script(dimensions, material, analysis_type, tolerances, forces, acoustic_properties) # Step 2: Run the simulation (e.g., structural, thermal, or acoustic) simulation_results = run_simulation(apdl_script, analysis_type) # Step 3: Generate G-Code (optional, based on CAD file or dimensions) gcode_file = generate_gcode(dimensions) return simulation_results, gcode_file # Gradio Interface with additional parameters for forces, tolerances, and acoustic properties interface = gr.Interface( fn=automate_workflow, inputs=[ gr.Textbox(label="Dimensions (e.g., 100x50x30 mm)", placeholder="Enter dimensions in mm"), gr.Textbox(label="Material (e.g., Steel)", placeholder="Enter material"), gr.Dropdown(label="Analysis Type", choices=["Structural", "Thermal", "Acoustic"]), gr.Textbox(label="Tolerances (e.g., ±0.05 mm)", placeholder="Enter tolerances"), gr.Textbox(label="Forces (e.g., 500 N)", placeholder="Enter forces"), gr.Textbox(label="Acoustic Properties (e.g., Sound absorption rate)", placeholder="Enter acoustic properties") ], outputs=[ gr.Text(label="Simulation Results"), gr.File(label="Generated G-Code File") ], title="ANSYS Simulation Automation with Additional Parameters" ) if __name__ == "__main__": interface.launch()