Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from modules.cad_generation import create_cad_model
|
| 3 |
+
from modules.simulation import run_simulation
|
| 4 |
+
from modules.toolpath_generation import generate_gcode
|
| 5 |
+
from modules.visualization import plot_simulation_results
|
| 6 |
+
|
| 7 |
+
def demo_workflow(dimensions, tolerances, materials, script_file, model_file):
|
| 8 |
+
# Step 1: Generate CAD Model
|
| 9 |
+
cad_result = create_cad_model(float(dimensions))
|
| 10 |
+
|
| 11 |
+
# Step 2: Run Simulation
|
| 12 |
+
sim_result = run_simulation(script_file.name)
|
| 13 |
+
|
| 14 |
+
# Step 3: Generate G-Code for CNC
|
| 15 |
+
gcode_result = generate_gcode(model_file.name)
|
| 16 |
+
|
| 17 |
+
# Step 4: Visualize Results (Mock Data for Demo)
|
| 18 |
+
visualization = plot_simulation_results({"stress": [10, 20, 30], "strain": [0.1, 0.2, 0.3]})
|
| 19 |
+
|
| 20 |
+
# Consolidate Results
|
| 21 |
+
return f"""
|
| 22 |
+
Workflow Completed:
|
| 23 |
+
CAD Model: {cad_result}
|
| 24 |
+
Simulation: {sim_result}
|
| 25 |
+
G-Code: {gcode_result}
|
| 26 |
+
""", visualization
|
| 27 |
+
|
| 28 |
+
# Gradio Interface
|
| 29 |
+
interface = gr.Interface(
|
| 30 |
+
demo_workflow,
|
| 31 |
+
inputs=[
|
| 32 |
+
gr.Textbox(label="Dimensions (e.g., 10)", placeholder="Enter dimensions in mm"),
|
| 33 |
+
gr.Textbox(label="Tolerances", placeholder="Enter tolerances in mm"),
|
| 34 |
+
gr.Textbox(label="Materials", placeholder="Enter material type (e.g., Aluminum)"),
|
| 35 |
+
gr.File(label="Simulation Script (APDL File)"),
|
| 36 |
+
gr.File(label="CAD Model File (SCAD File)"),
|
| 37 |
+
],
|
| 38 |
+
outputs=[
|
| 39 |
+
gr.Textbox(label="Workflow Summary"),
|
| 40 |
+
gr.Image(label="Simulation Visualization"),
|
| 41 |
+
],
|
| 42 |
+
title="Advanced Automation Workflow Demo",
|
| 43 |
+
description="This demo showcases CAD generation, simulation, and CNC G-Code generation."
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
if __name__ == "__main__":
|
| 47 |
+
interface.launch()
|