234 lines
11 KiB
HTML
234 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Glossary: Script Commands | HiAPI-C# 2025 </title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="title" content="Glossary: Script Commands | 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 "{query}"">
|
|
<meta name="loc:searchNoResults" content="No results for "{query}"">
|
|
<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="Glossary-ScriptCommand">
|
|
<h1 id="glossary-script-commands">Glossary: Script Commands</h1>
|
|
|
|
<h2 id="what-is-a-script-command">What Is a Script Command?</h2>
|
|
<p>A <strong>script command</strong> is a C# statement executed by the HiNC scripting engine. Scripts directly reference members and methods of <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html">SessionShell</a>, which serves as the global scope — no explicit object reference is needed.</p>
|
|
<pre><code class="lang-csharp">// These are all SessionShell members used directly as globals
|
|
EnablePhysics = true;
|
|
MachiningResolution_mm = 0.125;
|
|
PlayNcFile("NC/file1.nc");
|
|
Message("Done");
|
|
</code></pre>
|
|
<h2 id="script-syntax-basics">Script Syntax Basics</h2>
|
|
<p>Scripts use <strong>native C#</strong> syntax:</p>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Feature</th>
|
|
<th>Syntax</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>Statement terminator</td>
|
|
<td><code>;</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>End-of-line comment</td>
|
|
<td><code>// comment</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>String interpolation</td>
|
|
<td><code>$"Value is {variable}"</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Positive infinity</td>
|
|
<td><code>double.PositiveInfinity</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Negative infinity</td>
|
|
<td><code>double.NegativeInfinity</code></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Bitwise OR (for flags)</td>
|
|
<td><code>Fx|Fy|Fz</code></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>All standard C# language features (variables, loops, conditionals, LINQ, etc.) are available.</p>
|
|
<hr>
|
|
<h2 id="script-task-page">Script Task Page</h2>
|
|
<p>In the HiNC GUI, the <strong>Task</strong> page contains one or more script panels. Each panel has:</p>
|
|
<ul>
|
|
<li><strong>Order</strong>: Execution order (left to right, top to bottom)</li>
|
|
<li><strong>Enabled</strong>: Whether the script runs (unchecked = skipped)</li>
|
|
<li><strong>Title</strong>: A label for human reference only — has no functional effect</li>
|
|
</ul>
|
|
<hr>
|
|
<h2 id="execution-model">Execution Model</h2>
|
|
<h3 id="session-lifecycle">Session Lifecycle</h3>
|
|
<ol>
|
|
<li>Scripts execute in order on the <strong>Task</strong> page</li>
|
|
<li>A <a class="xref" href="../../api/Hi.Common.PacePlayer.html">PacePlayer</a><small>(API)</small> controls playback — script commands like <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_PlayNcFile_">PlayNcFile</a><small>(API)</small> block until the NC program completes</li>
|
|
<li>Player control commands (<a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_Pace">Pace()</a><small>(API)</small>, <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_Pause">Pause()</a><small>(API)</small>, <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_Reset">Reset()</a><small>(API)</small>) interact with the <a class="xref" href="../../api/Hi.Common.PacePlayer.html">PacePlayer</a><small>(API)</small></li>
|
|
<li><a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_ResetRuntime_">ResetRuntime</a><small>(API)</small> clears event handlers, buffers, and runtime state</li>
|
|
</ol>
|
|
<h3 id="event-driven-execution">Event-Driven Execution</h3>
|
|
<p>Events like <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_SessionStepBuilt">SessionStepBuilt</a><small>(API)</small> fire during simulation and allow per-step logic:</p>
|
|
<pre><code class="lang-csharp">SessionStepBuilt += (preStep, curStep) => {
|
|
if (curStep != null)
|
|
Message($"Step: ToolId={curStep.ToolId}");
|
|
};
|
|
PlayNcFile("NC/file1.nc");
|
|
</code></pre>
|
|
<p>Events are cleared by <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_ResetRuntime_">ResetRuntime</a>.</p>
|
|
<hr>
|
|
<h2 id="script-commands-in-nc-code">Script Commands in NC Code</h2>
|
|
<p>Script commands can be embedded inside NC code comments. Lines starting with <code>;@</code> execute before that NC line runs:</p>
|
|
<pre><code>T01 M06 (;@MachiningResolution_mm=0.03125;)
|
|
S1270 M03
|
|
G43 Z10. H01
|
|
</code></pre>
|
|
<p>For controllers that do not support <code>;</code> as a comment character (e.g., FANUC), wrap in a comment block:</p>
|
|
<pre><code>T01 M06 (;@MachiningResolution_mm=0.03125;)
|
|
</code></pre>
|
|
<hr>
|
|
<h2 id="file-path-templates">File Path Templates</h2>
|
|
<p>Commands that output files support the <code>[NcName]</code> token, which is replaced with each NC file name:</p>
|
|
<pre><code class="lang-csharp">PlayNcFile("NC/file1.nc");
|
|
PlayNcFile("NC/file2.nc");
|
|
WriteShotFiles("Output/[NcName].shot.csv", 1);
|
|
// Produces: Output/file1.nc.shot.csv, Output/file2.nc.shot.csv
|
|
</code></pre>
|
|
<p>All file paths are relative to the <strong>project directory</strong> unless an absolute path is given.</p>
|
|
<hr>
|
|
<h2 id="important-warnings">Important Warnings</h2>
|
|
<p>The following operations can corrupt simulation state or produce incorrect results:</p>
|
|
<ul>
|
|
<li><strong>Do not save the project during simulation.</strong> System-internal configuration (e.g., training-specific resolution overrides) may overwrite your settings.</li>
|
|
<li><strong>Do not reset the player during milling coefficient training.</strong> Close the project instead of pressing the reset button to avoid unexpected errors.</li>
|
|
<li><strong>Do not modify resolution, tool, or controller settings during training.</strong> Changing these mid-training invalidates the results.</li>
|
|
<li><strong>Do not combine <code>UpdateNcOptOption</code> in <a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_SessionStepBuilt">SessionStepBuilt</a><small>(API)</small> with NC-embedded optimization commands.</strong> Parallel computation may cause undefined behavior.</li>
|
|
</ul>
|
|
<hr>
|
|
<h2 id="global-variables">Global Variables</h2>
|
|
<p><a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html#Hi_MachiningProcs_SessionShell_Global">Global</a> provides a key-value dictionary for sharing data across scripts:</p>
|
|
<pre><code class="lang-csharp">Global["material"] = "Steel";
|
|
var material = Global["material"];
|
|
</code></pre>
|
|
<hr>
|
|
<h2 id="full-api-reference">Full API Reference</h2>
|
|
<p>For the complete list of available commands, properties, and events, see:</p>
|
|
<ul>
|
|
<li><a class="xref" href="../../api/Hi.MachiningProcs.SessionShell.html">SessionShell</a> — full API documentation</li>
|
|
<li><a class="xref" href="session-shell.html">Glossary: SessionShell Quick-Reference</a> — categorized quick-reference table</li>
|
|
</ul>
|
|
<h2 id="see-also">See Also</h2>
|
|
<ul>
|
|
<li><a class="xref" href="session-shell.html">Glossary: SessionShell Quick-Reference</a> — SessionShell quick-reference</li>
|
|
<li><a class="xref" href="step.html">Step</a> — machining step data model</li>
|
|
<li><a class="xref" href="../../workflows/basic-simulation.html">Workflow: Basic Machining Simulation</a> — using scripts in a simulation workflow</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>
|