287 lines
12 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Workflow: Geometry Validation | HiAPI-C# 2025 </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Workflow: Geometry Validation | HiAPI-C# 2025 ">
<link rel="icon" href="../img/HiAPI.favicon.ico">
<link rel="stylesheet" href="../public/docfx.min.css">
<link rel="stylesheet" href="../public/main.css">
<meta name="docfx:navrel" content="../toc.html">
<meta name="docfx:tocrel" content="toc.html">
<meta name="docfx:rel" content="../">
<meta name="loc:inThisArticle" content="In this article">
<meta name="loc:searchResultsCount" content="{count} results for &quot;{query}&quot;">
<meta name="loc:searchNoResults" content="No results for &quot;{query}&quot;">
<meta name="loc:tocFilter" content="Filter by title">
<meta name="loc:nextArticle" content="Next">
<meta name="loc:prevArticle" content="Previous">
<meta name="loc:themeLight" content="Light">
<meta name="loc:themeDark" content="Dark">
<meta name="loc:themeAuto" content="Auto">
<meta name="loc:changeTheme" content="Change theme">
<meta name="loc:copy" content="Copy">
<meta name="loc:downloadPdf" content="Download PDF">
<script type="module" src="./../public/docfx.min.js"></script>
<script>
const theme = localStorage.getItem('theme') || 'auto'
document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
</script>
</head>
<body class="tex2jax_ignore" data-layout="" data-yaml-mime="">
<header class="bg-body border-bottom">
<nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
<div class="container-xxl flex-nowrap">
<a class="navbar-brand" href="../index.html">
<img id="logo" class="svg" src="../img/HiAPI.logo.png" alt="">
</a>
<button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
<i class="bi bi-three-dots"></i>
</button>
<div class="collapse navbar-collapse" id="navpanel">
<div id="navbar">
<form class="search" role="search" id="search">
<i class="bi bi-search"></i>
<input class="form-control" id="search-query" type="search" disabled placeholder="Search" autocomplete="off" aria-label="Search">
</form>
</div>
</div>
</div>
</nav>
</header>
<main class="container-xxl">
<div class="toc-offcanvas">
<div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
<div class="offcanvas-header">
<h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
</div>
<div class="offcanvas-body">
<nav class="toc" id="toc"></nav>
</div>
</div>
</div>
<div class="content">
<div class="actionbar">
<button class="btn btn-lg border-0 d-md-none" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
<i class="bi bi-list"></i>
</button>
<nav id="breadcrumb"></nav>
</div>
<article data-uid="Workflow-GeometryValidation">
<h1 id="workflow-geometry-validation">Workflow: Geometry Validation</h1>
<p>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.</p>
<pre><code class="lang-mermaid">flowchart TD
Simulate[&quot;Run simulation&quot;]
Collision[&quot;Collision detection&quot;]
Diff[&quot;Geometry difference comparison&quot;]
Defect[&quot;Geometry defect scanning&quot;]
FlyPiece[&quot;Flying piece removal&quot;]
Simulate --&gt; Collision
Simulate --&gt; Diff
Simulate --&gt; Defect
Simulate --&gt; FlyPiece
</code></pre>
<hr>
<h2 id="1-collision-detection">1. Collision Detection</h2>
<p>Collision detection monitors whether the tool, holder, or spindle collides with the workpiece, fixture, or machine during simulation. Enable it <strong>before</strong> running the simulation.</p>
<h3 id="script-commands">Script Commands</h3>
<pre><code class="lang-csharp">EnableCollisionDetection = true;
EnablePauseOnCollision = false; // set true to pause on collision
</code></pre>
<table>
<thead>
<tr>
<th>Property</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>EnableCollisionDetection</code></td>
<td>Enables collision checking during simulation</td>
</tr>
<tr>
<td><code>EnablePauseOnCollision</code></td>
<td>Pauses execution when a collision is detected</td>
</tr>
</tbody>
</table>
<h3 id="combined-with-pause-on-failure">Combined with Pause on Failure</h3>
<p><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_EnablePauseOnFailure">EnablePauseOnFailure</a> provides a broader pause-on-error mechanism:</p>
<pre><code class="lang-csharp">EnablePauseOnFailure = true;
EnableCollisionDetection = true;
PlayNcFile(&quot;NC/file1.nc&quot;); // pauses if a collision occurs
</code></pre>
<h3 id="gui-operation">GUI Operation</h3>
<p>Enable collision detection in the main options panel before simulation.</p>
<div class="TIP">
<h5>Tip</h5>
<p>Collision detection adds computation overhead. For exploratory simulations where speed matters, you can disable it and re-enable for final validation.</p>
</div>
<hr>
<h2 id="2-geometry-difference-comparison">2. Geometry Difference Comparison</h2>
<p>The <code>Diff</code> command compares the simulated workpiece shape against a target (design) shape to identify over-cut and under-cut regions.</p>
<h3 id="script-command">Script Command</h3>
<pre><code class="lang-csharp">Diff(&lt;DetectionRadius_mm&gt;);
</code></pre>
<p><strong>Detection Radius</strong> is the surface extension distance for the target shape. Deviations beyond this distance are not computed. Larger values take longer.</p>
<pre><code class="lang-csharp">Diff(1); // detection radius = 1 mm
</code></pre>
<h3 id="interpreting-results">Interpreting Results</h3>
<p>After comparison, the workpiece surface is color-coded:</p>
<ul>
<li><strong>Green</strong>: Within tolerance</li>
<li><strong>Red (positive)</strong>: Over-cut exceeding the threshold</li>
<li><strong>Blue (positive)</strong>: Under-cut exceeding the threshold</li>
</ul>
<div class="NOTE">
<h5>Note</h5>
<p>The path index on the workpiece surface is <strong>invalidated</strong> after running <code>Diff</code>. If you need to inspect individual step paths, do so before calling <code>Diff</code>.</p>
</div>
<h3 id="case-study-reciprocating-slope-interference">Case Study: Reciprocating Slope Interference</h3>
<p>CAM-generated NC code may contain subtle errors that are invisible without geometric comparison. Common issues found through <code>Diff</code>:</p>
<table>
<thead>
<tr>
<th>Issue</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Right-angle wall under-cut</td>
<td>Under-cut near walls where target geometry has sharp corners</td>
</tr>
<tr>
<td>Inconsistent Z plunging</td>
<td>Over-cut from inconsistent Z values in reciprocating plunge regions</td>
</tr>
<tr>
<td>Insufficient radius clearance</td>
<td>Under-cut at reciprocating edges where the tool hasn't moved out by its radius</td>
</tr>
<tr>
<td>Zebra-pattern under-cut</td>
<td>Under-cut stripes from excessive reciprocating path spacing</td>
</tr>
</tbody>
</table>
<div class="TIP">
<h5>Tip</h5>
<p>Without software comparison, these issues can only be discovered after physical machining, significantly impacting precision manufacturing.</p>
</div>
<hr>
<h2 id="3-geometry-defect-scanning">3. Geometry Defect Scanning</h2>
<p>Geometry defect scanning helps debug abnormal workpiece or tool geometry. This is typically used only when geometry construction problems are suspected.</p>
<h3 id="scanruntimegeominfdefect">ScanRuntimeGeomInfDefect</h3>
<p><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ScanRuntimeGeomInfDefect_">ScanRuntimeGeomInfDefect</a> scans for infinite edge cut defects in the runtime geometry. After scanning, defect areas are rendered with colored markers.</p>
<pre><code class="lang-csharp">ScanRuntimeGeomInfDefect();
</code></pre>
<p>Return values:</p>
<ul>
<li><code>true</code> — defects detected</li>
<li><code>false</code> — no defects</li>
<li><code>null</code> — unable to execute (e.g., workpiece does not exist)</li>
</ul>
<h3 id="workflow-scan-before-simulation">Workflow: Scan Before Simulation</h3>
<pre><code class="lang-csharp">ScanRuntimeGeomInfDefect();
Pause(); // visually inspect defects
ClearDefectDisplayee(); // clear markers
PlayNcFile(&quot;NC/file1.nc&quot;);
</code></pre>
<h3 id="cleardefectdisplayee">ClearDefectDisplayee</h3>
<p><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_ClearDefectDisplayee_">ClearDefectDisplayee</a> removes defect markers from the workpiece:</p>
<pre><code class="lang-csharp">ClearDefectDisplayee();
</code></pre>
<div class="NOTE">
<h5>Note</h5>
<p>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.</p>
</div>
<hr>
<h2 id="4-flying-piece-removal">4. Flying Piece Removal</h2>
<p>During five-axis cutting, small disconnected residual material fragments (&ldquo;flying pieces&rdquo;) may appear. Use <code>RemoveFlyPiece</code> to clean them up.</p>
<h3 id="script-command-1">Script Command</h3>
<pre><code class="lang-csharp">RemoveFlyPiece();
</code></pre>
<div class="TIP">
<h5>Tip</h5>
<p>Run <code>RemoveFlyPiece</code> after simulation and before geometry export (<code>WriteRuntimeGeomToStl</code>) to produce a clean output.</p>
</div>
<hr>
<h2 id="combined-validation-script-example">Combined Validation Script Example</h2>
<pre><code class="lang-csharp">// Configure and run simulation with collision detection
EnableCollisionDetection = true;
EnablePauseOnCollision = false;
EnablePhysics = true;
MachiningResolution_mm = 0.125;
PlayNcFile(&quot;NC/file1.nc&quot;);
// 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(&quot;Geometry defects detected&quot;);
}
// Export final geometry
WriteRuntimeGeomToStl(&quot;Output/final.stl&quot;);
WriteStepFiles(&quot;Output/[NcName].step.csv&quot;);
</code></pre>
<h2 id="see-also">See Also</h2>
<ul>
<li><a class="xref" href="basic-simulation.html">Workflow: Basic Machining Simulation</a> — basic simulation setup</li>
<li><a class="xref" href="../manual/runtime/runtime-api.html">Glossary: RuntimeApi Quick-Reference</a> — RuntimeApi quick-reference</li>
</ul>
</article>
<div class="contribution d-print-none">
</div>
<div class="next-article d-print-none border-top" id="nextArticle"></div>
</div>
<div class="affix">
<nav id="affix"></nav>
</div>
</main>
<div class="container-xxl search-results" id="search-results"></div>
<footer class="border-top text-secondary">
<div class="container-xxl">
<div class="flex-fill">
<span> Copyright © 2025 <a href='https://superhightech.com.tw'>Tech Coordinate</a>. All rights reserved. <a href='https://superhightech.com.tw'>超級高科技股份有限公司</a> © 2025 版權所有 </span>
</div>
</div>
</footer>
</body>
</html>