Workflow: Geometry Validation
This workflow covers the suite of tools for validating machining geometry after simulation, including collision detection, geometry difference comparison, defect scanning, and flying piece removal.
flowchart TD
Simulate["Run simulation"]
Collision["Collision detection"]
Diff["Geometry difference comparison"]
Defect["Geometry defect scanning"]
FlyPiece["Flying piece removal"]
Simulate --> Collision
Simulate --> Diff
Simulate --> Defect
Simulate --> FlyPiece
1. Collision Detection
Collision detection monitors whether the tool, holder, or spindle collides with the workpiece, fixture, or machine during simulation. Enable it before running the simulation.
Script Commands
EnableCollisionDetection = true;
EnablePauseOnCollision = false; // set true to pause on collision
| Property | Description |
|---|---|
EnableCollisionDetection |
Enables collision checking during simulation |
EnablePauseOnCollision |
Pauses execution when a collision is detected |
Combined with Pause on Failure
EnablePauseOnFailure provides a broader pause-on-error mechanism:
EnablePauseOnFailure = true;
EnableCollisionDetection = true;
PlayNcFile("NC/file1.nc"); // pauses if a collision occurs
GUI Operation
Enable collision detection in the main options panel before simulation.
Tip
Collision detection adds computation overhead. For exploratory simulations where speed matters, you can disable it and re-enable for final validation.
2. Geometry Difference Comparison
The Diff command compares the simulated workpiece shape against a target (design) shape to identify over-cut and under-cut regions.
Script Command
Diff(<DetectionRadius_mm>);
Detection Radius is the surface extension distance for the target shape. Deviations beyond this distance are not computed. Larger values take longer.
Diff(1); // detection radius = 1 mm
Interpreting Results
After comparison, the workpiece surface is color-coded:
- Green: Within tolerance
- Red (positive): Over-cut exceeding the threshold
- Blue (positive): Under-cut exceeding the threshold
Note
The path index on the workpiece surface is invalidated after running Diff. If you need to inspect individual step paths, do so before calling Diff.
Case Study: Reciprocating Slope Interference
CAM-generated NC code may contain subtle errors that are invisible without geometric comparison. Common issues found through Diff:
| Issue | Description |
|---|---|
| Right-angle wall under-cut | Under-cut near walls where target geometry has sharp corners |
| Inconsistent Z plunging | Over-cut from inconsistent Z values in reciprocating plunge regions |
| Insufficient radius clearance | Under-cut at reciprocating edges where the tool hasn't moved out by its radius |
| Zebra-pattern under-cut | Under-cut stripes from excessive reciprocating path spacing |
Tip
Without software comparison, these issues can only be discovered after physical machining, significantly impacting precision manufacturing.
3. Geometry Defect Scanning
Geometry defect scanning helps debug abnormal workpiece or tool geometry. This is typically used only when geometry construction problems are suspected.
ScanRuntimeGeomInfDefect
ScanRuntimeGeomInfDefect scans for infinite edge cut defects in the runtime geometry. After scanning, defect areas are rendered with colored markers.
ScanRuntimeGeomInfDefect();
Return values:
true— defects detectedfalse— no defectsnull— unable to execute (e.g., workpiece does not exist)
Workflow: Scan Before Simulation
ScanRuntimeGeomInfDefect();
Pause(); // visually inspect defects
ClearDefectDisplayee(); // clear markers
PlayNcFile("NC/file1.nc");
ClearDefectDisplayee
ClearDefectDisplayee removes defect markers from the workpiece:
ClearDefectDisplayee();
Note
Defect markers are automatically cleared when the workpiece is reloaded or the runtime geometry is reset. During workpiece initialization, if construction defects are detected, markers are automatically displayed.
4. Flying Piece Removal
During five-axis cutting, small disconnected residual material fragments (“flying pieces”) may appear. Use RemoveFlyPiece to clean them up.
Script Command
RemoveFlyPiece();
Tip
Run RemoveFlyPiece after simulation and before geometry export (WriteRuntimeGeomToStl) to produce a clean output.
Combined Validation Script Example
// Configure and run simulation with collision detection
EnableCollisionDetection = true;
EnablePauseOnCollision = false;
EnablePhysics = true;
MachiningResolution_mm = 0.125;
PlayNcFile("NC/file1.nc");
// Remove any flying pieces
RemoveFlyPiece();
// Compare against target geometry (1 mm detection radius)
Diff(1);
// Scan for geometry defects
var hasDefects = ScanRuntimeGeomInfDefect();
if (hasDefects == true)
{
WarningMessage("Geometry defects detected");
}
// Export final geometry
WriteRuntimeGeomToStl("Output/final.stl");
WriteStepFiles("Output/[NcName].step.csv");
See Also
- Workflow: Basic Machining Simulation — basic simulation setup
- Glossary: RuntimeApi Quick-Reference — RuntimeApi quick-reference