Turning a 3D shape into a Computer Numerical Control (CNC) program is still largely manual. For every part, a machinist chooses setups, tools, step-downs, and toolpath patterns. We present Geo2Gcode, which converts a target mesh directly into standard G-code through structured machining primitives. Each primitive couples an indexed machining direction, a closed per-view reconstruction of the target, and explicit tool-radius, layer-height, and clearing-pattern parameters, and compiles deterministically into layerwise toolpaths via signed-distance queries. Most of the fidelity comes from this compiler. A lightweight selector trained with a voxel stock simulator fills in primitive parameters without per-part manual settings, approaching the finest fixed setting at about a quarter of its toolpath length. In simulation on ABC parts, Geo2Gcode reaches roughing fidelity comparable to an expert-tuned commercial CAM setup with a moderately longer toolpath, and clearly improves on a default CAM configuration. Generated programs run in a commercial G-code simulator, and one part is machined on a physical CNC mill. These results demonstrate that roughing programs can be generated directly from geometry without per-part CAM tuning.
Figures & tables
Figure 1: Overview of our proposed pipeline. From a target shape, our system generates G-code with initial setup and tool configuration, then inspects its stock-removal sequence in a CNC simulator. The bottom row shows a qualitative physical machining case, from stock setup to the machined workpiece.
Figure 2: The framework of Geo2Gcode. The orientation module first produces an ordered set of views. At each view, the contour pass is mandatory, while the DQN selects one of three clearing strategies together with tool radius and layer height. The resulting G-code is simulated to compute a reward balancing reconstruction fidelity and simulated cutting time.
Figure 3: Tool orientation selection process and visibility-based reconstructions.
Method
Tuning
ABC
ShapeNet
IoU ↑
F1 ↑
CD ↓
NC ↑
IoU ↑
F1 ↑
CD ↓
NC ↑
CSG-Stump [ 27 ]
✓
0.787
0.879
0.428
0.884
0.697
0.827
0.521
0.866
ExtrudeNet [ 28 ]
✓
0.769
0.875
0.505
0.871
0.607
0.773
0.918
0.844
CAPRI-Net [ 38 ]
✓
0.768
0.866
0.312
0.914
0.700
0.824
0.447
0.895
SECAD-Net [ 21 ]
✓
0.776
0.867
0.398
0.900
0.650
0.784
2.405
0.852
CNC-Net [ 36 ]
✗
0.780
0.889
1.127
0.864
0.698
0.817
2.154
0.844
Table 1: Geometric fidelity on ABC [ 17 ] (50 test shapes) and ShapeNet [ 2 ] (130 test shapes). Tuning: per-shape adaptation (five episodes for ours). Baselines output CAD primitives (top four) or CNC operations (CNC-Net), whereas ours outputs executable G-code. CD is scaled by 103 .
Figure 5: Qualitative comparisons. Our outputs are rendered in the CIMCO G-code simulator. Red highlights the simulated machined surface exposed by the cutting operations, and gray denotes stock that remains after simulation.
Figure 6: Toolpath simulation in machining order.
Figure 7: Zero-shot generalization to out-of-domain shapes.
Figure 8: Repeated-run 95% confidence intervals on ABC (ten random seeds per method, same shapes). Means differ slightly from the single-run values in Table 1 .
Method
IoU ↑
F1 ↑
CD ↓
NC ↑
CSG-Stump
0.751
0.856
0.645
0.858
ExtrudeNet
0.735
0.852
0.743
0.842
CAPRI-Net
0.728
0.846
0.624
0.883
SECAD-Net
0.742
0.845
0.765
0.872
CNC-Net
0.772
0.884
1.204
0.858
Ours
0.827
0.899
0.525
0.910
Table 2: Untuned evaluation on all 1,000 ABC test shapes. No method uses per-shape tuning.
Parameter policy
IoU ↑
F1 ↑
CD ↓
NC ↑
T ↓
Random
0.781
0.863
0.905
0.521
533.5
Fixed (fine)
0.856
0.917
0.427
0.936
1634.0
Fixed (coarse)
0.718
0.818
0.666
0.853
129.1
Fixed (const. triple)
0.788
0.897
0.583
0.901
1219.0
Fixed (const. triple, alt.)
0.793
0.872
0.574
0.923
627.4
Greedy sim. search
0.821
0.907
0.471
0.918
641.3
Table 3: Parameter-selection policies on 50 ABC shapes. All rows share the same orientations, path generator, and simulator, and only the per-view parameter choice differs. T is the normalized simulator cutting-time proxy. Alt.: another point of the same constant-triple sweep. Greedy: per view, simulate all 42 actions and keep the one with the highest per-view reward (Eq. 7 ).
Method
IoU ↑
F1 ↑
CD ↓
NC ↑
T ↓
MeshCAM (non-expert)
0.783
0.854
1.474
0.868
1488.6
MeshCAM (expert)
0.833
0.904
0.555
0.910
375.7
Ours (no tuning)
0.837
0.907
0.493
0.914
451.3
Ours (5-ep. tuning)
0.848
0.912
0.460
0.922
423.1
Ours, axis-aligned
0.834
0.905
0.501
0.920
451.6
Table 4: Comparison with commercial CAM (MeshCAM) on the same 50 ABC meshes. The expert setting is tuned per part by a machinist, whereas ours involves no manual input. T is the normalized cutting-time proxy. Axis-aligned: ours with each part’s expert ±x/±y/±z setups (no tuning).
Metric
6-axes
Rand(5)
Rand(6)
Ours
Coverage
ABC
92.67
83.52
89.11
96.42
ShapeNet
91.27
79.77
84.73
92.75
Table 5: Effect of tool orientation selection. Coverage: % of sampled surface points visible from the selected views.
Proxy
Non-exp.
Expert
Ours
Gouge ≤ 0.1 mm (%) ↑
89.61
92.31
98.57
Mean P95 overcut (mm) ↓
0.249
0.262
0.217
Local dim. variation ↓
0.678
0.726
0.228
Junction angle ( ∘ ) ↓
52.4
39.9
27.1
Curvature consistency ↓
1.15
7.57
0.69
Accel. violation rate ↓
1.8e-6
4.0e-4
1.3e-5
Table 6: Machining-quality proxies versus MeshCAM on all 50 ABC parts, scaled to 100 mm and weighted equally. Overcut is measured from the G-code against target-mesh samples, not the voxel grid. Path proxies assume 100 mm/min feed and 500 mm/s 2 acceleration.
Excluded
IoU ↑
F1 ↑
CD ↓
NC ↑
T ↓
Spiral
0.797
0.876
0.615
0.911
508.1
Periphery
0.806
0.882
0.565
0.914
529.0
Zigzag
0.811
0.886
0.611
0.917
441.3
Contour
0.756
0.849
0.891
0.847
444.4
None (Ours)
0.848
0.912
0.460
0.922
423.1
Table 7: Effect of toolpath strategies (ABC, 2563 ). Each row retrains without the named pattern, and all rows use five-episode adaptation.
Method
IoU ↑
F1 ↑
CD ↓
NC ↑
CNC-Net (per-shape tuned)
0.630
0.765
1.234
0.780
Ours (zero-shot)
0.770
0.866
0.710
0.859
Table 8: ShapeNet-to-OOD transfer on 20 unseen objects.
Excluded
IoU ↑
F1 ↑
CD ↓
NC ↑
T ↓
Rs
0.792
0.871
0.603
0.903
413.6
RMRR
0.851
0.914
0.456
0.921
774.8
None (Ours)
0.848
0.912
0.460
0.922
423.1
Table 9: Effect of reward terms (ABC). Each row retrains without the named term, and all rows use five-episode adaptation.
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
Figure S2 : Qualitative comparisons on the ABC and ShapeNet datasets. Our outputs are rendered in the CIMCO G-code simulator. Red highlights the simulated machined surface exposed by the cutting operations, and gray denotes stock that remains after simulation.
Figure S3 : Qualitative effect of machining precision. Examples show the target, fixed coarse parameters (large tool radius and layer height), and our method.
Figure S4 : Comparison with Huang et al. [15] . While their method performs sample-specific fitting on these examples, our method produces competitive results in a zero-shot manner without per-sample optimization.
ABC 7K
ABC 15K
Method
Acc.
F1
Acc.
F1
DeepMill
96.3
97.2
96.3
97.3
Ours
96.5
98.2
96.8
98.4
Appendix
Table S1: Quantitative comparison with DeepMill on the ABC dataset.
Method
Path Smoothness ( ∘ ) ↓
Curv. consistency ↓
G1 segment-length std. (mm) ↓
Accel. violation ↓
MeshCAM (non-expert)
52.4 ± 9.6
1.15 ± 0.25
12.28 ± 7.21
1.77e-6
MeshCAM (expert)
39.9 ± 17.3
7.57 ± 12.2
8.23 ± 4.12
4.0e-4
Ours
27.1 ± 14.2
0.69 ± 0.24
7.75 ± 2.88
1.32e-5
Appendix
Table S2: Machining-relevant metrics comparison on the ABC dataset between our method and MeshCAM under non-expert and expert settings.
Method
Local dim. variation ↓
Gouging tol. ≤0.1 mm (%) ↑
Gouging tol. ≤0.2 mm (%) ↑
Mean per-part P95 overcut (mm) ↓
MeshCAM (non-expert)
0.678
89.61
90.03
0.249
MeshCAM (expert)
0.726
92.31
92.53
0.262
Ours
0.228
98.57
99.29
0.217
Appendix
Table S3: One-sided overcut proxies on CAD-origin ABC target samples (all 50 parts). Each metric is computed per part (expert setups averaged within the part) and then averaged with equal part weight. P95 is conditional on gouged samples within each part.
Figure S5 : Qualitative physical CNC case study. One part machined from one Geo2Gcode-generated program on a FANUC Robodrill using AL6061 stock and a flat endmill.
Figure S6 : Analysis on complex shapes. The greedy module first fixes the indexed orientations, and at each subsequent simulation step, the policy selects radius, layer height, and clearing strategy for the current orientation.
Resolution
Smooth
IoU ↑
F1 ↑
CD ↓
NC ↑
T ↓
643
✓
0.810
0.886
0.686
0.912
397.6
1283
✓
0.824
0.889
0.585
0.912
409.3
2563
✓
0.848
0.902
0.493
0.914
423.1
2563
✗
0.826
0.898
0.530
0.893
442.5
Appendix
Table S4: Ablation on voxel resolution and Laplacian smoothing. T is the common normalized simulator-time proxy.
Method
IoU ↑
F1 ↑
CD ↓
NC ↑
6-axes
0.792
0.876
0.711
0.881
Rand(5)
0.740
0.839
0.710
0.869
Rand(6)
0.751
0.846
0.700
0.873
Ours
0.848
0.912
0.460
0.922
Appendix
Table S5: Comparison of tool orientation strategies.
Method
Training budget
Total pretraining time (h)
CSG-Stump
1000 epochs
80
ExtrudeNet
1000 epochs
60
CAPRI-Net
1000 epochs
9
SECAD-Net
1000 epochs
8
CNC-Net
100 epochs
50
Ours
2,000 episodes
30
Appendix
Table S6: Comparison of training budgets and total pretraining time across different methods.
Method
Fine-tuning time per sample
CSG-Stump
60 min
ExtrudeNet
30 min
CAPRI-Net
3 min
SECAD-Net
3 min
CNC-Net
50 min
Ours
10 min
Appendix
Table S7: Per-sample fine-tuning time comparison.
Selector
Terminal IoU ↑
Time proxy ↓
Uniform random (expectation)
.5938
884.7
Learned (five seeds)
.7457
1258.5
Frozen heuristic
.7517
1492.8
Validation-selected fixed
.7682
945.5
Retrospective oracle
.7834
1057.3
Appendix
Table S8: Separate compact selector diagnostic on ten eligible held-out shapes. Time is path length divided by feed rate, not measured machine seconds. The oracle maximizes terminal IoU over all 144 sequences per shape.