replicator-workshop 0.1.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/PKG-INFO +4 -4
  2. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/README.md +3 -3
  3. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/pyproject.toml +1 -1
  4. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/config.py +1 -1
  5. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/evaluate.py +3 -2
  6. replicator_workshop-0.3.0/replicator/core/fasteners.py +52 -0
  7. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/materials.py +14 -8
  8. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/ops_engineering.py +53 -0
  9. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/physics.py +1 -1
  10. replicator_workshop-0.3.0/replicator/core/printcheck.py +167 -0
  11. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/program.py +6 -0
  12. replicator_workshop-0.3.0/replicator/core/recipes.py +139 -0
  13. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/render.py +3 -0
  14. replicator_workshop-0.3.0/replicator/core/slicer.py +119 -0
  15. replicator_workshop-0.3.0/replicator/knowledge/bearings.md +14 -0
  16. replicator_workshop-0.3.0/replicator/knowledge/fasteners.md +19 -0
  17. replicator_workshop-0.3.0/replicator/knowledge/fdm_rules.md +18 -0
  18. replicator_workshop-0.3.0/replicator/knowledge/landing_gear.md +18 -0
  19. replicator_workshop-0.3.0/replicator/knowledge/linkage_walker.md +14 -0
  20. replicator_workshop-0.3.0/replicator/knowledge/v8_engine.md +19 -0
  21. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/llm/client.py +59 -4
  22. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/llm/prompts/blueprint.md +7 -0
  23. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/llm/prompts/program.md +10 -0
  24. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Main.qml +6 -2
  25. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/viewport/EdgeMaterial.qml +2 -0
  26. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/viewport/HoloMaterial.qml +4 -0
  27. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/viewport/Viewport.qml +20 -3
  28. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qt/mesh_geometry.py +3 -0
  29. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/shaders/edge.frag +1 -1
  30. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/shaders/holo.frag +17 -1
  31. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator_workshop.egg-info/PKG-INFO +4 -4
  32. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator_workshop.egg-info/SOURCES.txt +17 -0
  33. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_accuracy.py +6 -0
  34. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_bench.py +62 -0
  35. replicator_workshop-0.3.0/tests/test_constrained.py +55 -0
  36. replicator_workshop-0.3.0/tests/test_hole.py +46 -0
  37. replicator_workshop-0.3.0/tests/test_materials.py +17 -0
  38. replicator_workshop-0.3.0/tests/test_printcheck.py +56 -0
  39. replicator_workshop-0.3.0/tests/test_recipes.py +52 -0
  40. replicator_workshop-0.3.0/tests/test_review.py +16 -0
  41. replicator_workshop-0.3.0/tests/test_slicer.py +56 -0
  42. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/LICENSE +0 -0
  43. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/__init__.py +0 -0
  44. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/app.py +0 -0
  45. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/__init__.py +0 -0
  46. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/assembly.py +0 -0
  47. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/blender_link.py +0 -0
  48. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/critique.py +0 -0
  49. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/drawing.py +0 -0
  50. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/dxf.py +0 -0
  51. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/explain.py +0 -0
  52. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/export.py +0 -0
  53. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/fit.py +0 -0
  54. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/importers.py +0 -0
  55. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/ops_advanced.py +0 -0
  56. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/printers.py +0 -0
  57. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/reverse.py +0 -0
  58. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/robot.py +0 -0
  59. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/core/step.py +0 -0
  60. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/gaming_pc_liquid.json +0 -0
  61. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/gas_generator_rocket.json +0 -0
  62. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/gas_generator_rocket_aero.json +0 -0
  63. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/house_two_bed.json +0 -0
  64. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/quadcopter_drone.json +0 -0
  65. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/raspberry_pi_5.json +0 -0
  66. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/rocket_engine.json +0 -0
  67. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/turbofan.json +0 -0
  68. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/fixtures/vector_engine.json +0 -0
  69. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/gpu.py +0 -0
  70. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/image3d/__init__.py +0 -0
  71. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/image3d/comfy.py +0 -0
  72. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/image3d/pipeline.py +0 -0
  73. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/image3d/sheet.py +0 -0
  74. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/__init__.py +0 -0
  75. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/car_wheel_corner.md +0 -0
  76. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/desk_lamp.md +0 -0
  77. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/desktop_pc.md +0 -0
  78. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/electronics_board.md +0 -0
  79. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/exoskeleton.md +0 -0
  80. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/house.md +0 -0
  81. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/light_aircraft.md +0 -0
  82. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/multirotor_drone.md +0 -0
  83. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/print_replica.md +0 -0
  84. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/rocket_engine.md +0 -0
  85. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/knowledge/turbofan.md +0 -0
  86. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/llm/__init__.py +0 -0
  87. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/llm/prompts/edit.md +0 -0
  88. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/llm/prompts/explain.md +0 -0
  89. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/llm/prompts/name_parts.md +0 -0
  90. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/llm/prompts/research_queries.md +0 -0
  91. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/mcp_server.py +0 -0
  92. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/Chip.qml +0 -0
  93. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/DockHeader.qml +0 -0
  94. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/Icon.qml +0 -0
  95. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/IconButton.qml +0 -0
  96. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/Kbd.qml +0 -0
  97. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/NumField.qml +0 -0
  98. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/Pill.qml +0 -0
  99. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/RCombo.qml +0 -0
  100. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/RMenu.qml +0 -0
  101. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/RSlider.qml +0 -0
  102. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/Segmented.qml +0 -0
  103. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/Swatch.qml +0 -0
  104. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/Theme.qml +0 -0
  105. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/Replicator/UI/qmldir +0 -0
  106. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/AgentPrompt.qml +0 -0
  107. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/AttributeManager.qml +0 -0
  108. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/Commander.qml +0 -0
  109. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/HolodeckPanel.qml +0 -0
  110. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/IssuesCard.qml +0 -0
  111. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/LedgerPanel.qml +0 -0
  112. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/MaterialShelf.qml +0 -0
  113. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/ObjectManager.qml +0 -0
  114. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/Preferences.qml +0 -0
  115. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/Presenter.qml +0 -0
  116. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/StatusBar.qml +0 -0
  117. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/Timeline.qml +0 -0
  118. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/panels/Welcome.qml +0 -0
  119. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/viewport/Callouts.qml +0 -0
  120. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/viewport/GridMaterial.qml +0 -0
  121. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/viewport/NavGizmo.qml +0 -0
  122. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qml/viewport/ReferenceMaterial.qml +0 -0
  123. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qt/__init__.py +0 -0
  124. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qt/bridge.py +0 -0
  125. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qt/drawing_sheet.py +0 -0
  126. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qt/envmap.py +0 -0
  127. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qt/library.py +0 -0
  128. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/qt/svg.py +0 -0
  129. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/research/__init__.py +0 -0
  130. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/research/lane.py +0 -0
  131. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/shaders/edge.vert +0 -0
  132. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/shaders/grid.frag +0 -0
  133. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/shaders/grid.vert +0 -0
  134. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/shaders/reference.frag +0 -0
  135. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/shaders/reference.vert +0 -0
  136. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator/voice.py +0 -0
  137. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator_workshop.egg-info/dependency_links.txt +0 -0
  138. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator_workshop.egg-info/entry_points.txt +0 -0
  139. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator_workshop.egg-info/requires.txt +0 -0
  140. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/replicator_workshop.egg-info/top_level.txt +0 -0
  141. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/setup.cfg +0 -0
  142. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_alignment_checks.py +0 -0
  143. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_bridge.py +0 -0
  144. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_core.py +0 -0
  145. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_corpus.py +0 -0
  146. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_critic_quality.py +0 -0
  147. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_drawing.py +0 -0
  148. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_dxf.py +0 -0
  149. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_explain.py +0 -0
  150. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_fit.py +0 -0
  151. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_import_safety.py +0 -0
  152. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_importers.py +0 -0
  153. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_kernel_quality.py +0 -0
  154. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_llm_parsing.py +0 -0
  155. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_mcp_server.py +0 -0
  156. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_ops_advanced.py +0 -0
  157. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_robot.py +0 -0
  158. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_roof_and_size.py +0 -0
  159. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/tests/test_step.py +0 -0
  160. {replicator_workshop-0.1.0 → replicator_workshop-0.3.0}/vendor/mcp-for-blender/LICENSE +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: replicator-workshop
3
- Version: 0.1.0
3
+ Version: 0.3.0
4
4
  Summary: You specify it, you build it: a sentence becomes a validated build program, an exact solid, a checked report and a printable file.
5
5
  License-Expression: MIT
6
6
  Project-URL: Source, https://github.com/T-Crypt/replicator
@@ -84,10 +84,10 @@ It is built for many kinds of work, and most of it needs neither a model nor a p
84
84
  |---|---|
85
85
  | Design a building | Walls, openings and a roof from one sentence; a floor plan and elevations on the drawing sheet; checks that the roof covers the walls |
86
86
  | Lay out electronics | Boards and parts at real scale from knowledge cards, ready for an enclosure |
87
- | Engineer a machine | Formula-driven ops (a Rao bell nozzle, involute gears, NACA wings), mass, centre of gravity, STEP for CAD |
87
+ | Engineer a machine | Formula-driven ops (a Rao bell nozzle, involute gears, NACA wings), ISO 273 screw holes, a print-in-place hinge recipe, mass, centre of gravity, STEP for CAD |
88
88
  | Simulate it | URDF and MJCF with mass, centre and inertia measured from the exact solid, ready for MuJoCo or ROS |
89
- | Understand an object | Import any of 24 formats and take it apart in Reverse; Explain writes a checked explanation, Present narrates it |
90
- | Make a replica | Scale and orient to fit any printer bed, refused rather than clipped when it does not fit |
89
+ | Understand an object | Import any of 24 formats and take it apart in Reverse; cut a section through any build (X) to see inside; Explain writes a checked explanation, Present narrates it |
90
+ | Make a replica | Scale and orient to fit any printer bed, refused rather than clipped when it does not fit; overhang, wall and small-feature checks per part; print time and cost through OrcaSlicer |
91
91
  | Train or test a model | A seeded benchmark scored by measuring the solid, and a corpus export where every row re-verifies |
92
92
 
93
93
  ## Quick start
@@ -38,10 +38,10 @@ It is built for many kinds of work, and most of it needs neither a model nor a p
38
38
  |---|---|
39
39
  | Design a building | Walls, openings and a roof from one sentence; a floor plan and elevations on the drawing sheet; checks that the roof covers the walls |
40
40
  | Lay out electronics | Boards and parts at real scale from knowledge cards, ready for an enclosure |
41
- | Engineer a machine | Formula-driven ops (a Rao bell nozzle, involute gears, NACA wings), mass, centre of gravity, STEP for CAD |
41
+ | Engineer a machine | Formula-driven ops (a Rao bell nozzle, involute gears, NACA wings), ISO 273 screw holes, a print-in-place hinge recipe, mass, centre of gravity, STEP for CAD |
42
42
  | Simulate it | URDF and MJCF with mass, centre and inertia measured from the exact solid, ready for MuJoCo or ROS |
43
- | Understand an object | Import any of 24 formats and take it apart in Reverse; Explain writes a checked explanation, Present narrates it |
44
- | Make a replica | Scale and orient to fit any printer bed, refused rather than clipped when it does not fit |
43
+ | Understand an object | Import any of 24 formats and take it apart in Reverse; cut a section through any build (X) to see inside; Explain writes a checked explanation, Present narrates it |
44
+ | Make a replica | Scale and orient to fit any printer bed, refused rather than clipped when it does not fit; overhang, wall and small-feature checks per part; print time and cost through OrcaSlicer |
45
45
  | Train or test a model | A seeded benchmark scored by measuring the solid, and a corpus export where every row re-verifies |
46
46
 
47
47
  ## Quick start
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "replicator-workshop"
7
- version = "0.1.0"
7
+ version = "0.3.0"
8
8
  description = "You specify it, you build it: a sentence becomes a validated build program, an exact solid, a checked report and a printable file."
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -13,7 +13,7 @@ Everything here is off until the operator turns it on in Preferences:
13
13
  printers list saved printer profiles: catalog ids ("bambu_x1c", ...) or custom dicts
14
14
  {"id", "name", "vendor", "bed_x", "bed_y", "height", "nozzle", "margin", "transport"} (core/printers.py)
15
15
  active_printer str the id of the printer prints are gated on; empty = no printer (exports stay printer-less)
16
- endpoints list more model engines, each {"name", "url", "model", "key_env"}: any OpenAI-compatible server
16
+ endpoints list more model engines, each {"name", "url", "model", "key_env", optional "constrained"}: any OpenAI-compatible server
17
17
  (a lab's checkpoint on vLLM, Ollama, a hosted API). key_env names the environment variable that
18
18
  holds the API key; the key itself never goes in this file. Example:
19
19
  {"name": "lab-ft", "url": "http://192.168.1.40:8000/v1", "model": "cad-ft-7b", "key_env": ""}
@@ -431,9 +431,10 @@ def _register_extensions() -> None:
431
431
  from . import ops_advanced, ops_engineering
432
432
  from .program import register
433
433
  prims = {**ops_advanced.PRIMITIVES, **ops_engineering.PRIMITIVES}
434
- register(prims, ops_advanced.MODIFIERS)
434
+ mods = {**ops_advanced.MODIFIERS, **ops_engineering.MODIFIERS}
435
+ register(prims, mods)
435
436
  EXT_PRIMITIVES.update(prims)
436
- EXT_MODIFIERS.update(ops_advanced.MODIFIERS)
437
+ EXT_MODIFIERS.update(mods)
437
438
 
438
439
 
439
440
  _register_extensions()
@@ -0,0 +1,52 @@
1
+ """Metric fastener tables: ISO 273 clearance holes, coarse-thread tap drills and heat-set insert holes, in mm.
2
+
3
+ The `hole` op reads these so the model picks a size and a fit and the code computes the diameter (principle P2).
4
+ Sources, fetched 2026-12-05 and kept in replicator/knowledge/fasteners.md: isocnc.com clearance-hole and
5
+ thread-size charts (ISO 273, tap drills), forgent3d.com clearance-hole chart (CNC Kitchen insert holes, the
6
+ 0.2 mm printed allowance).
7
+ """
8
+ from __future__ import annotations
9
+
10
+ __all__ = ["CLEARANCE", "TAP_DRILL", "INSERT", "FITS", "diameter", "sizes"]
11
+
12
+ # size -> (fine/close, medium/normal, coarse/loose)
13
+ CLEARANCE: dict[str, tuple[float, float, float]] = {
14
+ "M2": (2.2, 2.4, 2.6), "M2.5": (2.7, 2.9, 3.1), "M3": (3.2, 3.4, 3.6), "M4": (4.3, 4.5, 4.8),
15
+ "M5": (5.3, 5.5, 5.8), "M6": (6.4, 6.6, 7.0), "M8": (8.4, 9.0, 10.0), "M10": (10.5, 11.0, 12.0),
16
+ "M12": (13.0, 13.5, 14.5),
17
+ }
18
+ TAP_DRILL: dict[str, float] = {"M3": 2.5, "M4": 3.3, "M5": 4.2, "M6": 5.0, "M8": 6.8, "M10": 8.5, "M12": 10.2}
19
+ # size -> (hole diameter, insert length, minimum wall), CNC Kitchen standard length
20
+ INSERT: dict[str, tuple[float, float, float]] = {
21
+ "M2": (3.2, 3.0, 1.3), "M3": (4.0, 5.7, 1.6), "M4": (5.7, 8.1, 2.1), "M5": (6.5, 9.5, 2.6), "M6": (8.1, 12.7, 3.3),
22
+ }
23
+ FITS = ("close", "normal", "loose", "tap", "insert")
24
+
25
+
26
+ def sizes(fit: str) -> list[str]:
27
+ table = TAP_DRILL if fit == "tap" else INSERT if fit == "insert" else CLEARANCE
28
+ return list(table)
29
+
30
+
31
+ def diameter(size: str, fit: str = "normal", allowance: float = 0.0) -> float:
32
+ """The hole diameter for a metric screw `size` ("M3") and `fit`, plus a printed-hole `allowance`.
33
+
34
+ Raises ValueError naming the sizes that exist, so the model's repair round can pick one."""
35
+ size = str(size).upper().strip()
36
+ if fit not in FITS:
37
+ raise ValueError(f"fit must be one of {', '.join(FITS)}, not {fit!r}")
38
+ if fit == "tap":
39
+ table = TAP_DRILL
40
+ elif fit == "insert":
41
+ table = INSERT
42
+ else:
43
+ table = CLEARANCE
44
+ if size not in table:
45
+ raise ValueError(f"no {fit} hole for {size}; sizes: {', '.join(table)}")
46
+ if fit == "tap":
47
+ d = TAP_DRILL[size]
48
+ elif fit == "insert":
49
+ d = INSERT[size][0]
50
+ else:
51
+ d = CLEARANCE[size][("close", "normal", "loose").index(fit)]
52
+ return round(d + float(allowance), 3)
@@ -27,7 +27,7 @@ PRESETS: dict[str, tuple[str, str, dict]] = {
27
27
  "aluminium_7075": ("7075-T6, clear anodised", "Aerospace", {"base_color": [0.76, 0.77, 0.79], "metalness": 1.0, "roughness": 0.38}),
28
28
  "steel_maraging": ("Maraging steel", "Aerospace", {"base_color": [0.40, 0.41, 0.43], "metalness": 1.0, "roughness": 0.3}),
29
29
  "tungsten": ("Tungsten", "Aerospace", {"base_color": [0.45, 0.45, 0.47], "metalness": 1.0, "roughness": 0.34}),
30
- "carbon_cfrp_twill": ("CFRP twill, clear-coated", "Aerospace", {"base_color": [0.03, 0.032, 0.036], "metalness": 0.1, "roughness": 0.16}),
30
+ "carbon_cfrp_twill": ("CFRP twill, clear-coated", "Aerospace", {"base_color": [0.03, 0.032, 0.036], "metalness": 0.1, "roughness": 0.16, "clearcoat": 1.0}),
31
31
  "peek": ("PEEK", "Aerospace", {"base_color": [0.62, 0.52, 0.38], "metalness": 0.0, "roughness": 0.4}),
32
32
  "kevlar": ("Aramid (Kevlar)", "Aerospace", {"base_color": [0.78, 0.60, 0.14], "metalness": 0.0, "roughness": 0.6}),
33
33
  "tps_tile": ("Thermal tile (TPS)", "Aerospace", {"base_color": [0.035, 0.035, 0.04], "metalness": 0.0, "roughness": 0.88}),
@@ -39,12 +39,17 @@ PRESETS: dict[str, tuple[str, str, dict]] = {
39
39
  "carbon_fibre": ("Carbon fibre", "Polymer", {"base_color": [0.045, 0.048, 0.055], "metalness": 0.1, "roughness": 0.28}),
40
40
  "ceramic": ("Ceramic", "Polymer", {"base_color": [0.9, 0.89, 0.86], "metalness": 0.0, "roughness": 0.12}),
41
41
  "clay": ("Clay", "Polymer", {"base_color": [0.78, 0.76, 0.72], "metalness": 0.0, "roughness": 0.62}),
42
- "paint_orange": ("Safety orange", "Paint", {"base_color": [1.0, 0.36, 0.03], "metalness": 0.0, "roughness": 0.3}),
43
- "paint_red": ("Signal red", "Paint", {"base_color": [0.78, 0.04, 0.05], "metalness": 0.0, "roughness": 0.22}),
44
- "paint_yellow": ("Machine yellow", "Paint", {"base_color": [0.96, 0.72, 0.04], "metalness": 0.0, "roughness": 0.3}),
45
- "paint_green": ("Racing green", "Paint", {"base_color": [0.02, 0.22, 0.12], "metalness": 0.0, "roughness": 0.2}),
46
- "paint_blue": ("Cobalt blue", "Paint", {"base_color": [0.03, 0.16, 0.62], "metalness": 0.0, "roughness": 0.2}),
47
- "paint_white": ("Gloss white", "Paint", {"base_color": [0.9, 0.9, 0.9], "metalness": 0.0, "roughness": 0.16}),
42
+ "paint_orange": ("Safety orange", "Paint", {"base_color": [1.0, 0.36, 0.03], "metalness": 0.0, "roughness": 0.3, "clearcoat": 1.0}),
43
+ "paint_red": ("Signal red", "Paint", {"base_color": [0.78, 0.04, 0.05], "metalness": 0.0, "roughness": 0.22, "clearcoat": 1.0}),
44
+ "paint_yellow": ("Machine yellow", "Paint", {"base_color": [0.96, 0.72, 0.04], "metalness": 0.0, "roughness": 0.3, "clearcoat": 1.0}),
45
+ "paint_green": ("Racing green", "Paint", {"base_color": [0.02, 0.22, 0.12], "metalness": 0.0, "roughness": 0.2, "clearcoat": 1.0}),
46
+ "paint_blue": ("Cobalt blue", "Paint", {"base_color": [0.03, 0.16, 0.62], "metalness": 0.0, "roughness": 0.2, "clearcoat": 1.0}),
47
+ "paint_white": ("Gloss white", "Paint", {"base_color": [0.9, 0.9, 0.9], "metalness": 0.0, "roughness": 0.16, "clearcoat": 1.0}),
48
+ "glass_clear": ("Clear glass", "Glass", {"base_color": [0.86, 0.89, 0.91], "metalness": 0.0, "roughness": 0.04, "opacity": 0.22, "clearcoat": 1.0}),
49
+ "glass_smoked": ("Smoked glass", "Glass", {"base_color": [0.12, 0.13, 0.14], "metalness": 0.0, "roughness": 0.05, "opacity": 0.45, "clearcoat": 1.0}),
50
+ "glass_frosted": ("Frosted glass", "Glass", {"base_color": [0.85, 0.88, 0.90], "metalness": 0.0, "roughness": 0.55, "opacity": 0.5}),
51
+ "polycarbonate_clear": ("Polycarbonate, clear", "Glass", {"base_color": [0.85, 0.88, 0.90], "metalness": 0.0, "roughness": 0.08, "opacity": 0.3, "clearcoat": 0.6}),
52
+ "acrylic_tinted_blue": ("Acrylic, tinted blue", "Glass", {"base_color": [0.30, 0.55, 0.85], "metalness": 0.0, "roughness": 0.06, "opacity": 0.35, "clearcoat": 0.8}),
48
53
  "glow_holo": ("Holo glow", "Glow", {"base_color": [0.02, 0.10, 0.14], "metalness": 0.0, "roughness": 0.4, "emissive": [0.2, 0.85, 1.0]}),
49
54
  "glow_ember": ("Ember glow", "Glow", {"base_color": [0.14, 0.04, 0.01], "metalness": 0.0, "roughness": 0.4, "emissive": [1.0, 0.42, 0.08]}),
50
55
  "glow_plasma": ("Plasma glow", "Glow", {"base_color": [0.08, 0.03, 0.14], "metalness": 0.0, "roughness": 0.4, "emissive": [0.72, 0.38, 1.0]}),
@@ -68,7 +73,8 @@ def _view(d: dict) -> dict:
68
73
  c = [min(max(float(x), 0.0), 1.0) for x in (d.get("base_color") or [0.72, 0.73, 0.76])[:3]]
69
74
  e = [min(max(float(x), 0.0), 1.0) for x in (d.get("emissive") or [0, 0, 0])[:3]]
70
75
  return {"color": _hex(c), "emissive": _hex(e), "metalness": float(d.get("metalness", 0.0)),
71
- "roughness": float(d.get("roughness", 0.5))}
76
+ "roughness": float(d.get("roughness", 0.5)), "opacity": float(d.get("opacity", 1.0)),
77
+ "clearcoat": float(d.get("clearcoat", 0.0))}
72
78
 
73
79
 
74
80
  def _hex(c: list[float]) -> str:
@@ -210,6 +210,59 @@ def _build_grille(p: dict) -> Manifold:
210
210
  return plate - Manifold.batch_boolean(holes, OpType.Add)
211
211
 
212
212
 
213
+ _AXES = {"x": (0, 1), "y": (1, 1), "z": (2, 1), "-x": (0, -1), "-y": (1, -1), "-z": (2, -1)}
214
+
215
+
216
+ def _build_hole(p: dict, m: Manifold) -> Manifold:
217
+ """Cut metric screw holes into the input. The diameter comes from core/fasteners.py (ISO 273 clearance, tap
218
+ drill or heat-set insert), never from the model. `at` lists world points; a hole runs along `axis` through the
219
+ whole part, or `depth` mm from the point into the part (toward -axis) for a blind hole."""
220
+ from . import fasteners
221
+ try:
222
+ d = fasteners.diameter(p["size"], str(p.get("fit", "normal")), float(p.get("allowance", 0.0)))
223
+ except ValueError as e:
224
+ raise _err(f"hole: {e}")
225
+ axis = str(p.get("axis", "y")).lower()
226
+ if axis not in _AXES:
227
+ raise _err(f"hole axis must be one of {', '.join(_AXES)}")
228
+ k, sign = _AXES[axis]
229
+ pts = p["at"]
230
+ if not isinstance(pts, list) or not pts or not isinstance(pts[0], (list, tuple)):
231
+ pts = [pts]
232
+ if len(pts) > 200:
233
+ raise _err("hole: at most 200 holes per op")
234
+ lo, hi = np.array(m.bounding_box()[:3]), np.array(m.bounding_box()[3:])
235
+ segs = _optional_int(p, "segments", 32, 8, 128, "hole")
236
+ cutters = []
237
+ for pt in pts:
238
+ c = np.array([float(v) for v in pt][:3])
239
+ if c.size != 3:
240
+ raise _err("hole: each point in at is [x, y, z]")
241
+ if "depth" in p:
242
+ depth = _positive_float(p, "depth", "hole")
243
+ a, b = c[k] - sign * depth, c[k] + sign * 0.01 # from the surface point into the part
244
+ else:
245
+ a, b = lo[k] - 1.0, hi[k] + 1.0
246
+ length = abs(b - a)
247
+ cyl = Manifold.cylinder(length, d / 2, d / 2, segs) # along +Z from 0
248
+ start = min(a, b)
249
+ if k == 0:
250
+ cyl = cyl.rotate((0, 90, 0))
251
+ elif k == 1:
252
+ cyl = cyl.rotate((-90, 0, 0))
253
+ offset = c.copy()
254
+ offset[k] = start
255
+ cutters.append(cyl.translate(offset.tolist()))
256
+ out = m - Manifold.batch_boolean(cutters, OpType.Add)
257
+ if abs(out.volume() - m.volume()) < 1e-6:
258
+ raise _err("hole: no point in at touches the part; give points on or inside it")
259
+ return out
260
+
261
+
262
+ MODIFIERS = {
263
+ "hole": ({"size", "at"}, {"fit", "axis", "depth", "allowance", "segments"}, _wrap_builder(_build_hole)),
264
+ }
265
+
213
266
  PRIMITIVES = {
214
267
  "tube": ({"height", "radius", "wall"}, {"radius_top", "segments", "center"}, _wrap_builder(_build_tube)),
215
268
  "nozzle": ({"throat_radius", "expansion_ratio"},
@@ -17,7 +17,7 @@ DENSITY = ( # kg/m^3; first match in the material
17
17
  ("gold", 19300), ("tungsten", 19250), ("lead", 11340), ("copper", 8960), ("brass", 8500), ("bronze", 8800),
18
18
  ("inconel", 8440), ("nickel", 8900), ("steel", 7850), ("iron", 7870), ("chrome", 7190), ("gunmetal", 8700),
19
19
  ("titanium", 4430), ("ceramic", 3900), ("alumin", 2700), ("anodis", 2700), ("clay", 1800), ("glass", 2500), ("concrete", 2400), ("stone", 2600),
20
- ("tps", 150), ("carbon", 1600), ("composite", 1800), ("kevlar", 1440), ("peek", 1300), ("rubber", 1150), ("tyre", 1150), ("tire", 1150), ("polymer", 1200),
20
+ ("tps", 150), ("polycarbonate", 1200), ("carbon", 1600), ("composite", 1800), ("kevlar", 1440), ("peek", 1300), ("rubber", 1150), ("tyre", 1150), ("tire", 1150), ("polymer", 1200),
21
21
  ("plastic", 1200), ("abs", 1050), ("pla", 1240), ("nylon", 1150), ("wood", 600), ("foam", 50),
22
22
  ("acetal", 1410), ("acrylic", 1180), ("pmma", 1180), ("petg", 1270), ("pcb", 1850), ("fr4", 1850), ("silicon", 2330),
23
23
  ("coolant", 1050), ("led", 1200),
@@ -0,0 +1,167 @@
1
+ """Printability: what an FDM printer will struggle with, measured on the exact solid (FR-PR-15).
2
+
3
+ Three measurements per part, after the replica scale. Each part is judged as printed on its own, standing on its
4
+ lowest face with program Y up: a chip resting on a board is not an overhang, because a multi-part replica prints
5
+ its parts separately (core/fit.py splits it the same way). A part is attributed its own findings, never a figure
6
+ pooled across bodies (the dfam-check rule).
7
+ - overhang: area of down-facing surface steeper than the self-supporting angle, not resting on the bed;
8
+ - wall: local thickness from inward rays at area-weighted surface samples; reported as the 5th percentile (p05)
9
+ and the minimum, and judged on p05 because one ray grazing an edge can fake a thin minimum (the dfam-check rule);
10
+ - feature: the part's smallest bounding extent, the size of a pin, fin or railing.
11
+
12
+ The measurements are facts; the verdicts compare them with the cited limits in LIMITS and say which limit they
13
+ used. Wall thickness from rays is an approximation near edges and corners, labelled as such. Nothing here
14
+ certifies a print.
15
+ """
16
+ from __future__ import annotations
17
+
18
+ import math
19
+ from dataclasses import asdict, dataclass
20
+
21
+ import numpy as np
22
+
23
+ from .critique import Issue
24
+ from .evaluate import Shape
25
+
26
+ __all__ = ["LIMITS", "PartPrint", "measure", "issues", "report"]
27
+
28
+ UNIT_TO_MM = {"mm": 1.0, "cm": 10.0, "m": 1000.0}
29
+ # FDM with a 0.4 mm nozzle. Source: Protolabs Network (hubs.com) FDM design guide and key design considerations,
30
+ # fetched 2026-12-05 (replicator/knowledge/fdm_rules.md).
31
+ LIMITS = {
32
+ "wall_mm": 0.8, # "all 3D printers can print walls thicker than 0.8 mm"
33
+ "overhang_deg": 45.0, # self-supporting up to 45 degrees from vertical
34
+ "feature_mm": 0.8, # a feature thinner than a wall does not print
35
+ "source": "Protolabs Network FDM design guide (hubs.com), fetched 2026-12-05",
36
+ }
37
+ _RAYS_PER_PART = 300
38
+ _TRI_CHUNK = 20000
39
+
40
+
41
+ @dataclass
42
+ class PartPrint:
43
+ id: str
44
+ label: str
45
+ component: str
46
+ overhang_mm2: float
47
+ overhang_fraction: float
48
+ wall_p05_mm: float | None
49
+ wall_min_mm: float | None
50
+ wall_samples: int
51
+ feature_mm: float
52
+
53
+ def as_dict(self) -> dict:
54
+ return asdict(self)
55
+
56
+
57
+ def _mesh(shape: Shape, k: float) -> tuple[np.ndarray, np.ndarray]:
58
+ mesh = shape.manifold.to_mesh()
59
+ V = np.asarray(mesh.vert_properties[:, :3], np.float64) * k
60
+ F = np.asarray(mesh.tri_verts, np.int64)
61
+ return V, F
62
+
63
+
64
+ def _ray_hits(origins: np.ndarray, dirs: np.ndarray, tri: np.ndarray) -> np.ndarray:
65
+ """Nearest positive hit distance of each ray against triangles tri [m, 3, 3] (Moller-Trumbore); inf on a miss."""
66
+ best = np.full(len(origins), np.inf)
67
+ eps = 1e-9
68
+ for s in range(0, len(tri), _TRI_CHUNK):
69
+ t3 = tri[s:s + _TRI_CHUNK]
70
+ v0, e1, e2 = t3[:, 0], t3[:, 1] - t3[:, 0], t3[:, 2] - t3[:, 0]
71
+ p = np.cross(dirs[:, None, :], e2[None]) # [r, m, 3]
72
+ det = np.einsum("mk,rmk->rm", e1, p)
73
+ ok = np.abs(det) > eps
74
+ inv = np.where(ok, 1.0 / np.where(ok, det, 1.0), 0.0)
75
+ tv = origins[:, None, :] - v0[None]
76
+ u = np.einsum("rmk,rmk->rm", tv, p) * inv
77
+ q = np.cross(tv, e1[None])
78
+ v = np.einsum("rk,rmk->rm", dirs, q) * inv
79
+ t = np.einsum("mk,rmk->rm", e2, q) * inv
80
+ hit = ok & (u >= 0) & (v >= 0) & (u + v <= 1) & (t > 1e-6)
81
+ t = np.where(hit, t, np.inf)
82
+ best = np.minimum(best, t.min(axis=1))
83
+ return best
84
+
85
+
86
+ def _thickness(V: np.ndarray, F: np.ndarray, rng: np.random.Generator) -> np.ndarray:
87
+ tri = V[F]
88
+ n = np.cross(tri[:, 1] - tri[:, 0], tri[:, 2] - tri[:, 0])
89
+ area2 = np.linalg.norm(n, axis=1)
90
+ keep = area2 > 1e-12
91
+ if not keep.any():
92
+ return np.array([])
93
+ tri, n, area2 = tri[keep], n[keep], area2[keep]
94
+ n = n / area2[:, None]
95
+ k = min(_RAYS_PER_PART, len(tri))
96
+ idx = rng.choice(len(tri), size=k, replace=len(tri) < k, p=area2 / area2.sum())
97
+ a, b = rng.random(k), rng.random(k)
98
+ flip = a + b > 1
99
+ a[flip], b[flip] = 1 - a[flip], 1 - b[flip]
100
+ pts = tri[idx, 0] + a[:, None] * (tri[idx, 1] - tri[idx, 0]) + b[:, None] * (tri[idx, 2] - tri[idx, 0])
101
+ dirs = -n[idx] # outward normals, so inward is minus
102
+ d = _ray_hits(pts + dirs * 1e-4, dirs, tri)
103
+ return d[np.isfinite(d)]
104
+
105
+
106
+ def measure(shapes: list[Shape], units: str = "mm", scale: float = 1.0, seed: int = 0) -> list[PartPrint]:
107
+ """Measure every part at `scale` (the replica factor; 1 = full size), in millimetres."""
108
+ k = UNIT_TO_MM.get(units, 1.0) * float(scale)
109
+ limit = math.cos(math.radians(LIMITS["overhang_deg"])) # a normal pointing down more steeply than this
110
+ rng = np.random.default_rng(seed)
111
+ out = []
112
+ for s in shapes:
113
+ V, F = _mesh(s, k)
114
+ if len(F) == 0:
115
+ continue
116
+ tri = V[F]
117
+ bed = V[:, 1].min() # this part's own print bed
118
+ cross = np.cross(tri[:, 1] - tri[:, 0], tri[:, 2] - tri[:, 0])
119
+ area = np.linalg.norm(cross, axis=1) / 2
120
+ with np.errstate(invalid="ignore", divide="ignore"):
121
+ ny = np.where(area > 0, cross[:, 1] / (2 * area), 0.0)
122
+ on_bed = tri[:, :, 1].max(axis=1) <= bed + 0.2 # faces lying on the plate need no support
123
+ over = (ny < -limit) & ~on_bed
124
+ total = float(area.sum()) or 1.0
125
+ th = _thickness(V, F, rng)
126
+ ext = V.max(axis=0) - V.min(axis=0)
127
+ out.append(PartPrint(
128
+ id=s.id, label=s.label, component=s.component,
129
+ overhang_mm2=round(float(area[over].sum()), 1),
130
+ overhang_fraction=round(float(area[over].sum()) / total, 4),
131
+ wall_p05_mm=round(float(np.percentile(th, 5)), 3) if len(th) else None,
132
+ wall_min_mm=round(float(th.min()), 3) if len(th) else None,
133
+ wall_samples=int(len(th)),
134
+ feature_mm=round(float(ext.min()), 3),
135
+ ))
136
+ return out
137
+
138
+
139
+ def issues(parts: list[PartPrint], min_overhang_fraction: float = 0.02) -> list[Issue]:
140
+ """Warnings for the critic and the Issues panel; each names the limit and its source. Never `fix`: a model
141
+ should not chase a printability warning on a build nobody asked to print."""
142
+ src = LIMITS["source"]
143
+ found = []
144
+ for p in parts:
145
+ subject = p.component or p.id
146
+ if p.feature_mm < LIMITS["feature_mm"]:
147
+ found.append(Issue("print", "warn", subject,
148
+ f"{p.label} is {p.feature_mm:.2f} mm at its thinnest, under the "
149
+ f"{LIMITS['feature_mm']} mm a printer can lay down ({src}); thicken or drop it"))
150
+ elif p.wall_p05_mm is not None and p.wall_p05_mm < LIMITS["wall_mm"]:
151
+ found.append(Issue("print", "warn", subject,
152
+ f"{p.label} has walls near {p.wall_p05_mm:.2f} mm (p05 of {p.wall_samples} rays, "
153
+ f"min {p.wall_min_mm:.2f}; measured by rays, approximate near edges), under "
154
+ f"{LIMITS['wall_mm']} mm ({src})"))
155
+ if p.overhang_fraction >= min_overhang_fraction:
156
+ found.append(Issue("print", "warn", subject,
157
+ f"{p.label}: {p.overhang_mm2:.0f} mm2 ({p.overhang_fraction:.0%} of its surface) "
158
+ f"overhangs past {LIMITS['overhang_deg']:.0f} degrees and needs support or a new "
159
+ f"orientation ({src})"))
160
+ return found
161
+
162
+
163
+ def report(shapes: list[Shape], units: str = "mm", scale: float = 1.0) -> dict:
164
+ parts = measure(shapes, units, scale)
165
+ return {"scale": scale, "limits": dict(LIMITS), "parts": [p.as_dict() for p in parts],
166
+ "issues": [i.as_dict() for i in issues(parts)],
167
+ "not_checked": ["bridges", "trapped resin or powder", "warping", "layer-direction strength"]}
@@ -243,6 +243,12 @@ def validate(program: dict) -> list[str]:
243
243
 
244
244
 
245
245
  def check(program: dict) -> dict:
246
+ """Validate a program. `recipe` ops are first expanded in place into the ordinary ops they generate
247
+ (core/recipes.py), so what is validated, built and saved is a plain program."""
248
+ from . import recipes
249
+ errs = recipes.expand(program) if isinstance(program, dict) else []
250
+ if errs:
251
+ raise ProgramError(errs)
246
252
  errs = validate(program)
247
253
  if errs:
248
254
  raise ProgramError(errs)
@@ -0,0 +1,139 @@
1
+ """Mechanism recipes (FR-AI-3): worked parametric templates the model chooses and fills in instead of inventing.
2
+
3
+ A program op `{"id": "h", "op": "recipe", "params": {"recipe": "print_in_place_hinge", "length": 40, ...}}` is
4
+ expanded by `program.check` into ordinary ops (ids prefixed with the recipe op's id), so the result is a normal,
5
+ editable BuildProgram: the recipe only writes the numbers. Every number comes from the params and the formulas
6
+ here; the model picks the recipe and its interface values (principle P2).
7
+
8
+ Each recipe: (required params, optional params with defaults, expand(op) -> list of ops).
9
+ """
10
+ from __future__ import annotations
11
+
12
+ import math
13
+
14
+ __all__ = ["RECIPES", "expand", "describe"]
15
+
16
+
17
+ class RecipeError(ValueError):
18
+ pass
19
+
20
+
21
+ def _num(p: dict, key: str, lo: float, hi: float) -> float:
22
+ try:
23
+ v = float(p[key])
24
+ except (TypeError, ValueError):
25
+ raise RecipeError(f"{key} must be a number")
26
+ if not math.isfinite(v) or not lo <= v <= hi:
27
+ raise RecipeError(f"{key} must be between {lo:g} and {hi:g}, not {v:g}")
28
+ return v
29
+
30
+
31
+ def _hinge(op: dict) -> list[dict]:
32
+ """Print-in-place hinge lying flat along X, both leaves on the bed (y = 0), knuckle axis at y = R.
33
+
34
+ Leaf A carries the pin and the even knuckles; leaf B the odd knuckles, bored to the pin radius plus the
35
+ clearance. Every face between the two leaves is `clearance` apart: knuckle ends along X, the pin in B's bore,
36
+ each leaf plate from the other leaf's knuckles. Defaults follow fdm_rules.md (0.4 mm gap, 3 mm leaves)."""
37
+ p = {**HINGE_DEFAULTS, **op.get("params", {})}
38
+ L = _num(p, "length", 10, 500)
39
+ W = _num(p, "leaf_width", 4, 200)
40
+ t = _num(p, "thickness", 1, 20)
41
+ c = _num(p, "clearance", 0.1, 2)
42
+ n = int(_num(p, "knuckles", 3, 15))
43
+ if n % 2 == 0:
44
+ raise RecipeError("knuckles must be odd, so leaf A has a knuckle at each end")
45
+ R = t # knuckle radius: a knuckle twice the leaf thickness across
46
+ rp = 0.45 * R # pin radius
47
+ if rp - c < 0.4 or R - (rp + c) < 0.8: # pin and bore wall at least a printable line (fdm_rules.md)
48
+ raise RecipeError("thickness too small for this clearance: the pin or the knuckle wall would not print")
49
+ s = (L - (n - 1) * c) / n # knuckle segment length
50
+ if s < 2 * c + 1:
51
+ raise RecipeError("too many knuckles for this length")
52
+ oid = op["id"]
53
+ comp = op.get("component", oid)
54
+ mat = op.get("material")
55
+ base = {"component": comp, **({"material": mat} if mat else {})}
56
+ ops: list[dict] = []
57
+
58
+ def add(id_, kind, label, params, **extra):
59
+ ops.append({"id": f"{oid}_{id_}", "op": kind, "label": label, **base, "params": params, **extra})
60
+
61
+ reach = R + c # each plate starts this far from the axis
62
+ add("plate_a", "box", "Leaf A Plate", {"size": [L, t, W], "translate": [0, t / 2, -(reach + W / 2)]})
63
+ add("plate_b", "box", "Leaf B Plate", {"size": [L, t, W], "translate": [0, t / 2, reach + W / 2]})
64
+ a_parts, b_parts = [f"{oid}_plate_a"], [f"{oid}_plate_b"]
65
+ for i in range(n):
66
+ x = -L / 2 + i * (s + c) + s / 2
67
+ side = "a" if i % 2 == 0 else "b"
68
+ sign = -1 if side == "a" else 1
69
+ add(f"knuckle_{i}", "cylinder", f"Leaf {side.upper()} Knuckle {i + 1}",
70
+ {"radius": R, "height": s, "segments": 48, "rotate": [0, 0, 90], "translate": [x, R, 0]})
71
+ add(f"tab_{i}", "box", f"Leaf {side.upper()} Tab {i + 1}",
72
+ {"size": [s, t, reach], "translate": [x, t / 2, sign * reach / 2]})
73
+ (a_parts if side == "a" else b_parts).extend([f"{oid}_knuckle_{i}", f"{oid}_tab_{i}"])
74
+ add("pin", "cylinder", "Hinge Pin", {"radius": rp, "height": L, "segments": 40, "rotate": [0, 0, 90],
75
+ "translate": [0, R, 0]})
76
+ a_parts.append(f"{oid}_pin")
77
+ add("bore", "cylinder", "Pin Bore", {"radius": rp + c, "height": L + 2, "segments": 40, "rotate": [0, 0, 90],
78
+ "translate": [0, R, 0]})
79
+ add("leaf_b_body", "boolean", "Leaf B Body", {"mode": "union"}, inputs=b_parts)
80
+ ops.append({"id": f"{oid}_leaf_a", "op": "boolean", "label": "Leaf A with Pin", **base,
81
+ "params": {"mode": "union"}, "inputs": a_parts})
82
+ ops.append({"id": f"{oid}_leaf_b", "op": "boolean", "label": "Leaf B", **base,
83
+ "params": {"mode": "difference"}, "inputs": [f"{oid}_leaf_b_body", f"{oid}_bore"]})
84
+ place = {k: op["params"][k] for k in ("translate", "rotate") if k in op.get("params", {})}
85
+ if place: # place both leaves together
86
+ for leaf in ("leaf_a", "leaf_b"):
87
+ ops.append({"id": f"{oid}_{leaf}_placed", "op": "transform", "label": next(
88
+ o["label"] for o in ops if o["id"] == f"{oid}_{leaf}"), **base, "input": f"{oid}_{leaf}",
89
+ "params": dict(place)})
90
+ return ops
91
+
92
+
93
+ HINGE_DEFAULTS = {"leaf_width": 15.0, "thickness": 3.0, "clearance": 0.4, "knuckles": 5}
94
+
95
+ RECIPES = {
96
+ "print_in_place_hinge": ({"length"}, dict(HINGE_DEFAULTS), _hinge),
97
+ }
98
+
99
+
100
+ def describe() -> str:
101
+ """One line per recipe for the program prompt and op_reference."""
102
+ out = []
103
+ for name, (req, opt, _fn) in RECIPES.items():
104
+ o = ", ".join(f"{k} ({v:g})" for k, v in opt.items())
105
+ out.append(f"- {name}: required {', '.join(sorted(req))}; optional {o}; optional translate, rotate")
106
+ return "\n".join(out)
107
+
108
+
109
+ def expand(program: dict) -> list[str]:
110
+ """Replace every `recipe` op in place with the ops it generates. Returns errors (empty when all expanded)."""
111
+ errs: list[str] = []
112
+ ops = program.get("ops")
113
+ if not isinstance(ops, list) or not any(isinstance(o, dict) and o.get("op") == "recipe" for o in ops):
114
+ return errs
115
+ out = []
116
+ for i, op in enumerate(ops):
117
+ if not (isinstance(op, dict) and op.get("op") == "recipe"):
118
+ out.append(op)
119
+ continue
120
+ name = (op.get("params") or {}).get("recipe")
121
+ where = f"ops[{i}] ({op.get('id', '?')})"
122
+ if name not in RECIPES:
123
+ errs.append(f"{where}: unknown recipe {name!r}; recipes: {', '.join(RECIPES)}")
124
+ continue
125
+ req, opt, fn = RECIPES[name]
126
+ params = op.get("params") or {}
127
+ missing = sorted(set(req) - set(params))
128
+ unknown = sorted(set(params) - set(req) - set(opt) - {"recipe", "translate", "rotate"})
129
+ if missing or unknown:
130
+ errs += [f"{where}: {name} needs params {missing}" for _ in [0] if missing]
131
+ errs += [f"{where}: {name} does not take params {unknown}" for _ in [0] if unknown]
132
+ continue
133
+ try:
134
+ out.extend(fn(op))
135
+ except RecipeError as e:
136
+ errs.append(f"{where}: {name}: {e}")
137
+ if not errs:
138
+ ops[:] = out
139
+ return errs
@@ -52,6 +52,9 @@ def principled(name, spec):
52
52
  b.inputs["Transmission Weight"].default_value = 1.0 - a * 0.5
53
53
  b.inputs["IOR"].default_value = 1.45
54
54
  b.inputs["Alpha"].default_value = max(a, 0.15)
55
+ if float(spec.get("clearcoat", 0.0)) > 0: # paint, CFRP, glass: Principled coat layer
56
+ b.inputs["Coat Weight"].default_value = float(spec["clearcoat"])
57
+ b.inputs["Coat Roughness"].default_value = 0.04
55
58
  e = spec.get("emissive")
56
59
  if e and max(e) > 0:
57
60
  b.inputs["Emission Color"].default_value = (*[float(x) for x in e[:3]], 1)