fix SoftNcRunner GM code normalization.

This commit is contained in:
2026-05-06 13:21:19 +08:00
parent 0fe9497552
commit 2f57932000
1238 changed files with 69405 additions and 22511 deletions
@@ -0,0 +1,357 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Workflow: Basic Machining Simulation | HiAPI-C# 2025 </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="title" content="Workflow: Basic Machining Simulation | 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-BasicSimulation">
<h1 id="workflow-basic-machining-simulation">Workflow: Basic Machining Simulation</h1>
<p>This workflow walks through setting up and running a machining simulation from scratch, including project configuration, option tuning, NC execution, and result inspection.</p>
<pre><code class="lang-mermaid">flowchart TD
Equipment[&quot;Set machine tool &amp;&lt;br&gt;controller brand/type&quot;]
Job[&quot;Set workpiece, fixture,&lt;br&gt;tool house, NC files,&lt;br&gt;controller offsets&quot;]
Option[&quot;Tune simulation options&lt;br&gt;(resolution, physics, etc.)&quot;]
Run[&quot;Run simulation&quot;]
View[&quot;View results&quot;]
Equipment --&gt; Job --&gt; Option --&gt; Run --&gt; View
</code></pre>
<h2 id="1-set-machine-tool-and-controller">1. Set Machine Tool and Controller</h2>
<p>The machine tool and controller are fixed equipment that define the physical simulation environment.</p>
<h3 id="machine-tool">Machine Tool</h3>
<p>The machine tool (<code>.mt</code> file) provides the kinematic model and STL bodies. Once selected it rarely changes between simulations.</p>
<h3 id="controller">Controller</h3>
<p>Select the controller brand and type (e.g., Fanuc, Heidenhain, Siemens). This determines how NC code is interpreted. See <a href="../manual/setup/controller-heidenhain.html">Heidenhain Support</a> and <a href="../manual/setup/controller-iso.html">General NC Code Support</a> for details.</p>
<h3 id="gui-operation">GUI Operation</h3>
<p>Open or create a project in the HiNC application and configure machine tool and controller through the corresponding panels before setting up the job.</p>
<hr>
<h2 id="2-set-job-components">2. Set Job Components</h2>
<p>With equipment fixed, configure the job-specific components that change between simulations.</p>
<h3 id="job-components">Job Components</h3>
<table>
<thead>
<tr>
<th>Component</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong>Workpiece</strong></td>
<td>Geometry (STL or parametric), material, and coordinate frame</td>
</tr>
<tr>
<td><strong>Fixture</strong> (optional)</td>
<td>Fixture geometry that participates in collision detection</td>
</tr>
<tr>
<td><strong>Tool House</strong></td>
<td>One or more cutting tools with geometry and flute definitions</td>
</tr>
<tr>
<td><strong>NC Files</strong></td>
<td>The NC programs to simulate</td>
</tr>
<tr>
<td><strong>Controller Offsets</strong></td>
<td>Tool offset tables, work offset tables, and other controller-specific presets</td>
</tr>
</tbody>
</table>
<div class="TIP">
<h5>Tip</h5>
<p>All file paths used in script commands are relative to the project directory unless an absolute path is given.</p>
</div>
<h3 id="script-access">Script Access</h3>
<p>The workpiece and fixture objects are available through <a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Workpiece">Workpiece</a><small>(API)</small> and <a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Fixture">Fixture</a><small>(API)</small>.</p>
<pre><code class="lang-csharp">var workpiece = Workpiece;
var fixture = Fixture;
</code></pre>
<h3 id="gui-operation-1">GUI Operation</h3>
<p>Configure each component through the corresponding panels (Workpiece, Fixture, Tool House windows).</p>
<hr>
<h2 id="3-tune-simulation-options">3. Tune Simulation Options</h2>
<p>Simulation options control the trade-off between accuracy and speed.</p>
<h3 id="31-workpiece-entity-resolution">3.1 Workpiece Entity Resolution</h3>
<p><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_MachiningResolution_mm">MachiningResolution_mm</a><small>(API)</small> sets the smallest cube width of the workpiece mesh.</p>
<pre><code class="lang-csharp">MachiningResolution_mm = 0.125;
</code></pre>
<p>Valid values are <strong>powers of 2</strong> (e.g., 4, 2, 1, 0.5, 0.25, 0.125). If you supply a non-power-of-2 value the system rounds to the nearest power of 2.</p>
<div class="WARNING">
<h5>Warning</h5>
<p>Each halving of mesh width can increase computation time and RAM by up to <strong>8x</strong>. Start with a coarser resolution and refine only when needed.</p>
</div>
<h3 id="32-display-cache">3.2 Display Cache</h3>
<pre><code class="lang-csharp">DispCache_Mb = 260;
</code></pre>
<p>The display resolution depends on the cache size. Recommended value should not exceed 1000 Mb.</p>
<h3 id="33-machining-motion-resolution">3.3 Machining Motion Resolution</h3>
<p>Machining motion resolution determines the interval of each simulation step. Options:</p>
<table>
<thead>
<tr>
<th>Mode</th>
<th>Command</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>Feed Per Cycle</td>
<td><code>MachiningMotionResolution = FeedPerCycle;</code></td>
<td>One step per spindle revolution</td>
</tr>
<tr>
<td>Scaled Feed Per Cycle</td>
<td><code>MachiningMotionResolution = ScaledFeedPerCycle(0.5);</code></td>
<td>One step per revolution × scale factor</td>
</tr>
<tr>
<td>Feed Per Tooth</td>
<td><code>MachiningMotionResolution = FeedPerTooth;</code></td>
<td>One step per tooth revolution (default)</td>
</tr>
<tr>
<td>Fixed Pace</td>
<td><code>MachiningMotionResolution = FixedPace(1, 15);</code></td>
<td>Fixed linear (mm) and rotary (deg) resolution</td>
</tr>
</tbody>
</table>
<div class="WARNING">
<h5>Warning</h5>
<p><strong>Do not use scaled model dimensions as a substitute for adjusting mesh width.</strong> Scaling model dimensions causes internal algorithm thresholds (minimum cuttable amount, floating-point-to-fraction range) to become invalid, producing irregular geometry artifacts. Adjust resolution settings instead.</p>
</div>
<h3 id="34-xml-configuration">3.4 XML Configuration</h3>
<p>Resolution can also be set in the <code>.hincproj</code> file or changed mid-simulation via NC code comments:</p>
<pre><code>T01 M06 (;@MachiningResolution_mm=0.03125;)
</code></pre>
<hr>
<h2 id="4-run-simulation">4. Run Simulation</h2>
<p>There are three ways to drive the simulation.</p>
<h3 id="41-playncfile--execute-from-a-file">4.1 PlayNcFile — Execute from a File</h3>
<p><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_PlayNcFile_">PlayNcFile</a><small>(API)</small> reads and executes an NC file.</p>
<pre><code class="lang-csharp">PlayNcFile(&quot;NC/file1.nc&quot;);
</code></pre>
<h3 id="42-plaync--execute-from-a-string">4.2 PlayNc — Execute from a String</h3>
<p><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_PlayNc_">PlayNc</a><small>(API)</small> executes NC code directly from a string, useful for programmatic or dynamically generated commands.</p>
<pre><code class="lang-csharp">double x = 10.0;
PlayNc($&quot;G01 X{x} Y20 F100&quot;, &quot;Generated Command&quot;);
</code></pre>
<h3 id="43-playcsvfile--drive-from-csv-data">4.3 PlayCsvFile — Drive from CSV Data</h3>
<p><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_PlayCsvFile_">PlayCsvFile</a><small>(API)</small> drives the simulation from a CSV file containing axis positions, spindle speed, and feed rate.</p>
<pre><code class="lang-csharp">PlayCsvFile(&quot;Data/file1.csv&quot;);
</code></pre>
<p>Required CSV columns (default headers): <code>MC.X</code>, <code>MC.Y</code>, <code>MC.Z</code>, <code>ToolId</code>, <code>SpindleSpeed_rpm</code>, <code>Feedrate_mmdmin</code>. Optional: <code>MC.A</code>, <code>MC.B</code>, <code>MC.C</code>, <code>ActualTime</code>, <code>StepDuration</code>.</p>
<div class="TIP">
<h5>Tip</h5>
<p>CSV files exported by <a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_WriteStepFiles_">WriteStepFiles</a><small>(API)</small> can be directly read back with <a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_PlayCsvFile_">PlayCsvFile</a><small>(API)</small>.</p>
</div>
<h3 id="44-player-control">4.4 Player Control</h3>
<table>
<thead>
<tr>
<th>Command</th>
<th>Purpose</th>
</tr>
</thead>
<tbody>
<tr>
<td><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Pace">Pace()</a><small>(API)</small></td>
<td>Insert a pausable checkpoint</td>
</tr>
<tr>
<td><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Pause">Pause()</a><small>(API)</small></td>
<td>Pause execution</td>
</tr>
<tr>
<td><a class="xref" href="../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_Reset">Reset()</a><small>(API)</small></td>
<td>Reset player state</td>
</tr>
</tbody>
</table>
<pre><code class="lang-csharp">PlayNcFile(&quot;NC/file1.nc&quot;);
if (someCondition)
Pause();
</code></pre>
<hr>
<h2 id="5-view-results">5. View Results</h2>
<h3 id="51-runtime-geometry">5.1 Runtime Geometry</h3>
<p>After simulation the workpiece geometry is a <strong>Runtime Geometry</strong> (cubic mesh). You can save and reload it to avoid re-computing the initial shape:</p>
<pre><code class="lang-csharp">WriteRuntimeGeom(&quot;Cache/file1.wct&quot;);
WriteRuntimeGeomToStl(&quot;Output/file1.stl&quot;);
</code></pre>
<p>To reload a saved geometry for a subsequent run:</p>
<pre><code class="lang-csharp">ReadRuntimeGeom(&quot;Cache/init.wct&quot;);
PlayNcFile(&quot;NC/file1.nc&quot;);
</code></pre>
<h3 id="52-step-data-inspection">5.2 Step Data Inspection</h3>
<p>Each simulation step carries rich data (force, torque, power, thermal, wear). Access individual steps:</p>
<pre><code class="lang-csharp">var step = GetMillingStep(100);
Message($&quot;ToolId={step.ToolId}, Force={step.MaxAbsForce_N} N&quot;);
</code></pre>
<p>Total step count:</p>
<pre><code class="lang-csharp">var total = StepCount;
Message($&quot;Total steps: {total}&quot;);
</code></pre>
<h3 id="53-export-data">5.3 Export Data</h3>
<p>Export step-level CSV:</p>
<pre><code class="lang-csharp">WriteStepFiles(&quot;Output/[NcName].step.csv&quot;);
</code></pre>
<p>Export waveform (shot) CSV:</p>
<pre><code class="lang-csharp">WriteShotFiles(&quot;Output/[NcName].shot.csv&quot;, 1);
</code></pre>
<h3 id="54-messages">5.4 Messages</h3>
<p>Use messages to log and track simulation progress:</p>
<pre><code class="lang-csharp">Message(&quot;Simulation complete&quot;);
AppendMessagesToFile(&quot;Output/messages.txt&quot;);
</code></pre>
<hr>
<h2 id="troubleshooting">Troubleshooting</h2>
<table>
<thead>
<tr>
<th>Symptom</th>
<th>Likely Cause</th>
<th>Fix</th>
</tr>
</thead>
<tbody>
<tr>
<td>Very slow simulation</td>
<td>Resolution too fine</td>
<td>Increase <code>MachiningResolution_mm</code></td>
</tr>
<tr>
<td>Irregular bumps on geometry</td>
<td>Scaled model dimensions instead of resolution</td>
<td>Use resolution settings only; see warning above</td>
</tr>
<tr>
<td>Display lag</td>
<td><code>DispCache_Mb</code> too large</td>
<td>Reduce display cache (&lt; 1000 Mb recommended)</td>
</tr>
<tr>
<td>Empty step data</td>
<td>Simulation not run or tool not engaging workpiece</td>
<td>Verify tool path intersects the workpiece</td>
</tr>
</tbody>
</table>
<h2 id="see-also">See Also</h2>
<ul>
<li><a href="../manual/setup/controller-heidenhain.html">Heidenhain Support</a> — controller configuration</li>
<li><a href="../manual/setup/controller-iso.html">General NC Code Support</a> — ISO NC support</li>
<li><a href="../manual/runtime/step-intro.html">Simulation Step</a> — what a step is</li>
<li><a href="../manual/runtime/step-output.html">Simulation Step Output</a> — step field reference</li>
<li><a class="xref" href="../manual/runtime/script-command.html">Glossary: Script Commands</a> — script command basics</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>