jithenderchoudary commited on
Commit
967e1fd
·
verified ·
1 Parent(s): dddd058

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from utils.cad_operations import create_cad_model
3
+ from utils.toolpath_generation import generate_toolpath, generate_gcode
4
+
5
+ # Step 1: Collect user input parameters
6
+ def cnc_workflow(length, width, height, material, tool_size, operation_type):
7
+ """
8
+ Full CNC workflow from parameter input to G-code generation
9
+ """
10
+ # Step 2: Create CAD model
11
+ part = create_cad_model(length, width, height, material)
12
+
13
+ # Step 3: Generate Toolpath
14
+ toolpath = generate_toolpath(part, tool_size, operation_type)
15
+
16
+ # Step 4: Generate G-code
17
+ gcode_file = generate_gcode(toolpath)
18
+
19
+ return f"G-code file generated: {gcode_file}"
20
+
21
+ # Define the Gradio interface and layout
22
+ def build_gui():
23
+ with gr.Blocks() as demo:
24
+ # Title and Intro
25
+ gr.Markdown("### CNC G-Code Generation Workflow")
26
+
27
+ # Step 1: Input Parameters
28
+ with gr.Row():
29
+ length_input = gr.Number(label="Length (mm)", value=100)
30
+ width_input = gr.Number(label="Width (mm)", value=50)
31
+ height_input = gr.Number(label="Height (mm)", value=20)
32
+ material_input = gr.Dropdown(choices=["Aluminum", "Steel", "Plastic"], label="Material Type", value="Aluminum")
33
+
34
+ # Step 2: Tool and Operation Input
35
+ with gr.Row():
36
+ tool_size_input = gr.Number(label="Tool Size (mm)", value=5)
37
+ operation_input = gr.Dropdown(choices=["Milling", "Drilling"], label="Operation Type", value="Milling")
38
+
39
+ # Step 3: Button to Start G-Code Generation
40
+ generate_button = gr.Button("Generate G-Code")
41
+
42
+ # Step 4: Output section
43
+ output_text = gr.Textbox(label="Generated G-code File", interactive=False)
44
+
45
+ # Bind the button to the function
46
+ generate_button.click(cnc_workflow,
47
+ inputs=[length_input, width_input, height_input, material_input, tool_size_input, operation_input],
48
+ outputs=output_text)
49
+
50
+ return demo
51
+
52
+ # Launch the Gradio app
53
+ demo = build_gui()
54
+ demo.launch()