Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from modules.cad_generation import create_cad_model | |
| from modules.simulation import run_simulation | |
| from modules.toolpath_generation import generate_gcode | |
| from modules.visualization import plot_simulation_results | |
| def demo_workflow(dimensions, tolerances, materials, script_file, model_file): | |
| # Step 1: Generate CAD Model | |
| cad_result = create_cad_model(float(dimensions)) | |
| # Step 2: Run Simulation | |
| sim_result = run_simulation(script_file.name) | |
| # Step 3: Generate G-Code for CNC | |
| gcode_result = generate_gcode(model_file.name) | |
| # Step 4: Visualize Results (Mock Data for Demo) | |
| visualization = plot_simulation_results({"stress": [10, 20, 30], "strain": [0.1, 0.2, 0.3]}) | |
| # Consolidate Results | |
| return f""" | |
| Workflow Completed: | |
| CAD Model: {cad_result} | |
| Simulation: {sim_result} | |
| G-Code: {gcode_result} | |
| """, visualization | |
| # Gradio Interface | |
| interface = gr.Interface( | |
| demo_workflow, | |
| inputs=[ | |
| gr.Textbox(label="Dimensions (e.g., 10)", placeholder="Enter dimensions in mm"), | |
| gr.Textbox(label="Tolerances", placeholder="Enter tolerances in mm"), | |
| gr.Textbox(label="Materials", placeholder="Enter material type (e.g., Aluminum)"), | |
| gr.File(label="Simulation Script (APDL File)"), | |
| gr.File(label="CAD Model File (SCAD File)"), | |
| ], | |
| outputs=[ | |
| gr.Textbox(label="Workflow Summary"), | |
| gr.Image(label="Simulation Visualization"), | |
| ], | |
| title="Advanced Automation Workflow Demo", | |
| description="This demo showcases CAD generation, simulation, and CNC G-Code generation." | |
| ) | |
| if __name__ == "__main__": | |
| interface.launch() | |