Download gcode_analyzer_ui.py from nicoaspra/G-code_Programming_Assistant: direct link, hf CLI and curl.
- Browser
- Download file 2.22 kB
-
https://huggingface.co/spaces/nicoaspra/G-code_Programming_Assistant/resolve/2369b7b095019fdcc8ae58fc085f0a37cdaf96ea/gcode_analyzer_ui.py
- Command line
-
hf download hf://spaces/nicoaspra/G-code_Programming_Assistant@2369b7b095019fdcc8ae58fc085f0a37cdaf96ea/gcode_analyzer_ui.py
-
curl -L -o gcode_analyzer_ui.py https://huggingface.co/spaces/nicoaspra/G-code_Programming_Assistant/resolve/2369b7b095019fdcc8ae58fc085f0a37cdaf96ea/gcode_analyzer_ui.py
2.22 kB
| # app.py | |
| import streamlit as st | |
| from python_gcode_checker import run_checks | |
| from settings_report_details import generate_detailed_report | |
| def analyze_gcode(gcode, depth_max=0.1): | |
| errors, warnings = run_checks(gcode, depth_max) | |
| config_report = generate_detailed_report(gcode) | |
| return errors, warnings, config_report | |
| def format_issues(issues): | |
| formatted = [] | |
| for line_num, message in issues: | |
| if line_num > 0: | |
| formatted.append(f"Line {line_num}: {message}") | |
| else: | |
| formatted.append(message) # No "Line 0" for general warnings/errors | |
| return formatted | |
| # Streamlit UI | |
| st.title("G-code Programming Assistant (v0.1)") | |
| st.markdown(""" | |
| Welcome to the G-code Assistant! This tool helps you verify and analyze your G-code for potential errors and warnings before running it on your machine. | |
| **Note:** This tool is limited to simple carving operations on a CNC milling machine. | |
| This is a beta version, and you're free to use it for checking your G-codes. If you encounter any issues or unexpected behavior, please contact the developer at **nico.aspra@bicol-u.edu.ph**. | |
| """) | |
| # Input for maximum depth of cut | |
| depth_max = st.number_input("Maximum Depth of Cut", min_value=0.0, value=0.1, step=0.1, format="%.1f") | |
| # Text area for G-code input | |
| gcode_input = st.text_area("Input G-code", height=300, placeholder="Enter G-code here...") | |
| # Button to analyze G-code | |
| if st.button("Analyze G-code"): | |
| # Run analysis | |
| errors, warnings, config_report = analyze_gcode(gcode_input, depth_max) | |
| # Display Errors with count in the subheader | |
| st.subheader(f"Errors ({len(errors)})") | |
| if errors: | |
| for message in format_issues(errors): | |
| st.error(message) | |
| else: | |
| st.success("No errors found.") | |
| # Display Warnings with count in the subheader | |
| st.subheader(f"Warnings ({len(warnings)})") | |
| if warnings: | |
| for message in format_issues(warnings): | |
| st.warning(message) | |
| else: | |
| st.info("No warnings found.") | |
| # Display Configuration Settings | |
| st.subheader("Configuration Settings") | |
| st.text(config_report) | |
| # Footer | |
| st.markdown("---") | |
| st.markdown("Developed by **Aspra, N.**") |