Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,47 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import FreeCAD, Part
|
| 3 |
-
from ansys.mapdl.core import launch_mapdl
|
| 4 |
|
| 5 |
-
def
|
| 6 |
-
# Step 1:
|
| 7 |
-
|
| 8 |
-
doc = FreeCAD.newDocument(part_name)
|
| 9 |
-
box = Part.makeBox(length, width, height)
|
| 10 |
-
Part.show(box)
|
| 11 |
-
step_file = f"{part_name}.step"
|
| 12 |
-
box.exportStep(step_file)
|
| 13 |
-
except Exception as e:
|
| 14 |
-
return f"Error in FreeCAD CAD generation: {e}"
|
| 15 |
|
| 16 |
-
# Step 2:
|
| 17 |
-
|
| 18 |
-
mapdl = launch_mapdl()
|
| 19 |
-
mapdl.prep7()
|
| 20 |
-
mapdl.et(1, "SOLID186")
|
| 21 |
-
mapdl.mp("EX", 1, material_property) # Elastic modulus
|
| 22 |
-
mapdl.input(step_file)
|
| 23 |
-
mapdl.vmesh("ALL")
|
| 24 |
-
mapdl.solve()
|
| 25 |
-
displacement = mapdl.post_processing.nodal_displacement()
|
| 26 |
-
mapdl.exit()
|
| 27 |
-
except Exception as e:
|
| 28 |
-
return f"Error in ANSYS simulation: {e}"
|
| 29 |
|
| 30 |
-
|
|
|
|
| 31 |
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
|
|
|
| 35 |
inputs=[
|
| 36 |
-
gr.Textbox(label="
|
| 37 |
-
gr.
|
| 38 |
-
gr.
|
| 39 |
-
gr.Number(label="Height (mm)"),
|
| 40 |
-
gr.Number(label="Material Elastic Modulus (Pa)"),
|
| 41 |
],
|
| 42 |
-
outputs="text",
|
| 43 |
-
title="
|
| 44 |
-
description="Generate CAD models and perform ANSYS simulations automatically!"
|
| 45 |
)
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
| 1 |
+
from utils.cad_utils import generate_cad_model
|
| 2 |
+
from utils.simulation_utils import run_simulation
|
| 3 |
+
from utils.gcode_utils import generate_gcode
|
| 4 |
import gradio as gr
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
def automate_workflow(dimensions, material, tolerances):
|
| 7 |
+
# Step 1: Generate CAD model
|
| 8 |
+
cad_file = generate_cad_model(dimensions)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
# Step 2: Run simulation
|
| 11 |
+
simulation_results = run_simulation(cad_file)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
+
# Step 3: Generate G-Code
|
| 14 |
+
gcode_file = generate_gcode(cad_file)
|
| 15 |
|
| 16 |
+
return f"Simulation Results: {simulation_results}", gcode_file
|
| 17 |
+
|
| 18 |
+
interface = gr.Interface(
|
| 19 |
+
fn=automate_workflow,
|
| 20 |
inputs=[
|
| 21 |
+
gr.Textbox(label="Dimensions (e.g., 100x50x30 mm)"),
|
| 22 |
+
gr.Textbox(label="Material (e.g., Steel)"),
|
| 23 |
+
gr.Textbox(label="Tolerances (e.g., ±0.05 mm)")
|
|
|
|
|
|
|
| 24 |
],
|
| 25 |
+
outputs=["text", "file"],
|
| 26 |
+
title="End-to-End Automation Workflow"
|
|
|
|
| 27 |
)
|
| 28 |
|
| 29 |
+
if __name__ == "__main__":
|
| 30 |
+
interface.launch()
|