Spaces:
Sleeping
Sleeping
Delete generate_gcode
Browse files- generate_gcode +0 -38
generate_gcode
DELETED
|
@@ -1,38 +0,0 @@
|
|
| 1 |
-
def generate_gcode(cad_file):
|
| 2 |
-
"""
|
| 3 |
-
Generates a simple G-Code and saves it to a file.
|
| 4 |
-
Returns the file path of the generated G-Code file.
|
| 5 |
-
"""
|
| 6 |
-
try:
|
| 7 |
-
# Ensure the output directory exists
|
| 8 |
-
output_dir = "/mnt/data/"
|
| 9 |
-
os.makedirs(output_dir, exist_ok=True)
|
| 10 |
-
|
| 11 |
-
# Define the G-Code content
|
| 12 |
-
gcode_content = """
|
| 13 |
-
G21 ; Set units to millimeters
|
| 14 |
-
G17 ; Select XY plane
|
| 15 |
-
G90 ; Absolute positioning
|
| 16 |
-
G1 F1500 ; Set feed rate
|
| 17 |
-
|
| 18 |
-
G0 Z5 ; Raise Z-axis to safe height
|
| 19 |
-
G0 X0 Y0 ; Move to start position
|
| 20 |
-
G1 Z-1 F300 ; Lower Z-axis to cutting depth
|
| 21 |
-
|
| 22 |
-
G1 X10 Y0 ; Cut to the first corner
|
| 23 |
-
G1 X10 Y10 ; Cut to the second corner
|
| 24 |
-
G1 X0 Y10 ; Cut to the third corner
|
| 25 |
-
G1 X0 Y0 ; Return to the start position
|
| 26 |
-
|
| 27 |
-
G0 Z5 ; Raise Z-axis to safe height
|
| 28 |
-
M30 ; End program
|
| 29 |
-
"""
|
| 30 |
-
|
| 31 |
-
# Save the G-Code to a file
|
| 32 |
-
gcode_file = os.path.join(output_dir, "generated_gcode.nc")
|
| 33 |
-
with open(gcode_file, "w") as f:
|
| 34 |
-
f.write(gcode_content)
|
| 35 |
-
|
| 36 |
-
return gcode_file
|
| 37 |
-
except Exception as e:
|
| 38 |
-
return f"Error in G-Code generation: {e}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|