Problems to be fixed: add a mesh repair functions
A modular Python framework for analyzing STL files for CNC manufacturability issues.
- Modular Architecture: Each analysis function is in its own module
- Context-Aware Analysis: Smart detection that ignores false positives
- Interactive Web Interface: Streamlit-based UI for easy file upload and analysis
- Comprehensive Reporting: HTML, JSON, and Markdown report generation
- 3D Visualization: Interactive Plotly visualizations with problem highlighting
- Test Framework: Built-in testing system for validating analysis functions
- undercut_check.py: Detects surfaces that can't be machined from standard directions
- internal_volumes_check.py: Finds enclosed spaces that can't be accessed
- steep_walls_check.py: Identifies problematic vertical walls in deep pockets
- narrow_channels_check.py: Detects channels too narrow for standard tools
- small_features_check.py: Finds features smaller than minimum tool size
- deep_pockets_check.py: Identifies pockets that may be too deep for standard tools
- geometric_context.py: Provides context-aware analysis helpers
pip install -r requirements.txtstreamlit run app.pyThen:
- Upload your STL file
- Configure analysis parameters
- Select which analyses to run
- View results and download reports
from cnc_analyzer import CNCAnalyzer
# Create analyzer
analyzer = CNCAnalyzer()
# Load mesh
analyzer.load_mesh("your_part.stl")
# Run single analysis
result = analyzer.analyze_single_function("undercuts")
# Run all analyses
results = analyzer.analyze_all()
# Get score
score = analyzer.calculate_score()
print(f"CNC Manufacturability Score: {score}/100")from test_framework import TestFramework
# Create tester
tester = TestFramework()
# Create synthetic test cases
tester.create_test_cases()
# Run tests on all cases
results = tester.test_all_cases()
# Generate comparison report
summary = tester.generate_comparison_report(results)Default configuration in cnc_analyzer.py:
{
'min_tool_diameter': 3.0, # mm
'min_channel_width': 2.0, # mm
'steep_angle_threshold': 80.0, # degrees
'deep_pocket_threshold': 30.0, # mm
'min_depth': 5.0, # mm
'use_context_aware': True,
'analysis_methods': {
'undercuts': True,
'internal_volumes': True,
'small_features': True,
'steep_walls': True,
'narrow_channels': True,
'deep_pockets': True
}
}- 90-100: Excellent - Perfect for standard CNC
- 80-89: Good - Minor issues, easily machinable
- 70-79: Fair - Some challenges, may need special tools
- 50-69: Difficult - Requires advanced CNC or redesign
- 0-49: Very Difficult - Major redesign recommended
Place STL files in the test_cases directory and run:
tester = TestFramework("test_cases")
results = tester.test_all_cases()- HTML Report: Comprehensive report with visualizations
- JSON Report: Machine-readable format for integration
- Markdown Report: Human-readable text format
The analyzer includes smart detection that:
- Ignores external surfaces (they're good for CNC)
- Checks tool accessibility from multiple directions
- Considers geometric context before flagging issues
- Reduces false positives from mesh tessellation
To add a new analysis:
- Create a new module (e.g.,
new_check.py) - Implement analysis function following the pattern:
def analyze_new_feature(mesh, **kwargs): return { 'count': count, 'indices': indices, 'has_problem': bool, 'severity': level, 'data': metadata }
- Add to
CNCAnalyzer.analyze_single_function() - Update scoring logic in
calculate_score()
@software{trimesh, author = {{Dawson-Haggerty et al.}}, title = {trimesh}, url = {https://trimesh.org/}, version = {3.2.0}, date = {2019-12-8}, }