226 lines
9.5 KiB
HTML
226 lines
9.5 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<title>加工步變數 | HiAPI-C# 2025 </title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="title" content="加工步變數 | 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="Cmd-StepVariables">
|
||
<h1 id="加工步變數">加工步變數</h1>
|
||
|
||
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html">RuntimeApi</a><small>(API)</small> 提供了多個方法來處理和存取加工步的變數。</p>
|
||
<h2 id="預設步輸出資訊">預設步輸出資訊</h2>
|
||
<p>每個加工步都包含豐富的預設輸出資訊,涵蓋來源行、運動學、載荷、力/力矩、功率、熱與磨耗等。</p>
|
||
<p>完整的預設步輸出資訊說明,請參考 <a class="xref" href="../../output/simulation-step-output.html">仿真步輸出資訊(Simulation Step Output)</a>。</p>
|
||
<div class="TIP">
|
||
<h5>Tip</h5>
|
||
<p><strong>存取預設步資訊範例</strong></p>
|
||
<pre><code class="lang-csharp">PlayNcFile("NC/file1.nc");
|
||
|
||
// 取得步並存取預設資訊
|
||
var step = GetMillingStep(100); // 見下方「存取步資訊」
|
||
if (step != null)
|
||
{
|
||
// 存取預設的步資訊
|
||
Message($"ToolId: {step.ToolId}");
|
||
Message($"Feedrate: {step.Feedrate_mmdmin} mm/min");
|
||
Message($"ChipVolume: {step.ChipVolume_mm3} mm³");
|
||
Message($"MaxAbsForce: {step.MaxAbsForce_N} N");
|
||
}
|
||
</code></pre>
|
||
</div>
|
||
<h2 id="註冊步變數">註冊步變數</h2>
|
||
<p>除了預設的步輸出資訊外,您可以使用 <a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_RegisterStepVariable_">RegisterStepVariable</a><small>(API)</small> 註冊自訂的步變數,用於追蹤特定的計算結果或資料。</p>
|
||
<p>註冊的步變數主要用於人類檢視,可透過工件幾何體上的顏色顯示數值分布。搭配 <a class="xref" href="../../../../../api/Hi.MachiningSteps.MachiningStep.html#Hi_MachiningSteps_MachiningStep_Item_System_String_">this[string]</a><small>(API)</small> 索引器可實現完整的資料檢查功能:</p>
|
||
<ul>
|
||
<li><code>RegisterStepVariable</code>:註冊變數供介面顯示及輸出</li>
|
||
<li><code>MachiningStep[key]</code>:在腳本中讀寫步的自訂資料</li>
|
||
</ul>
|
||
<h3 id="registerstepvariable">RegisterStepVariable</h3>
|
||
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_RegisterStepVariable_">RegisterStepVariable</a><small>(API)</small> 註冊一個步變數,用於在執行過程中追蹤特定資料。</p>
|
||
<div class="NOTE">
|
||
<h5>Note</h5>
|
||
<p><strong>指令格式</strong></p>
|
||
<pre><code class="lang-csharp">RegisterStepVariable(<鍵值>, <名稱>, <單位>, <格式字串>, <變數函數>);
|
||
</code></pre>
|
||
</div>
|
||
<div class="TIP">
|
||
<h5>Tip</h5>
|
||
<p><strong>指令範例</strong></p>
|
||
<pre><code class="lang-csharp">// 註冊一個計算切削體積的步變數
|
||
RegisterStepVariable(
|
||
"ChipVolume",
|
||
"Chip Volume",
|
||
"mm3",
|
||
"F2",
|
||
(step) => step.ChipVolume_mm3
|
||
);
|
||
|
||
PlayNcFile("NC/file1.nc");
|
||
</code></pre>
|
||
</div>
|
||
<h3 id="參數說明">參數說明</h3>
|
||
<ul>
|
||
<li><code><鍵值></code>: 變數的唯一識別碼</li>
|
||
<li><code><名稱></code>: 變數的顯示名稱</li>
|
||
<li><code><單位></code>: 變數的物理單位(可為 null)</li>
|
||
<li><code><格式字串></code>: 數值格式化字串(可為 null)</li>
|
||
<li><code><變數函數></code>: 從步計算變數值的函數(可為 null)</li>
|
||
</ul>
|
||
<div class="NOTE">
|
||
<h5>Note</h5>
|
||
<p>註冊的步變數可以在輸出檔案(如 <a class="xref" href="../WriteStepFiles/index.html">輸出步資料檔案</a>)中使用,並在介面中顯示。</p>
|
||
</div>
|
||
<h2 id="存取步資訊">存取步資訊</h2>
|
||
<h3 id="getmillingstep">GetMillingStep</h3>
|
||
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_GetMillingStep_">GetMillingStep</a><small>(API)</small> 取得指定索引的加工步。</p>
|
||
<div class="NOTE">
|
||
<h5>Note</h5>
|
||
<p><strong>指令格式</strong></p>
|
||
<pre><code class="lang-csharp">var step = GetMillingStep(<步索引>);
|
||
</code></pre>
|
||
</div>
|
||
<div class="TIP">
|
||
<h5>Tip</h5>
|
||
<p><strong>指令範例</strong></p>
|
||
<pre><code class="lang-csharp">PlayNcFile("NC/file1.nc");
|
||
|
||
// 取得第100個步
|
||
var step = GetMillingStep(100);
|
||
if (step != null)
|
||
{
|
||
Message($"Step 100: ToolId={step.ToolId}, Feedrate={step.Feedrate_mmdmin}");
|
||
}
|
||
</code></pre>
|
||
</div>
|
||
<h3 id="stepcount">StepCount</h3>
|
||
<p><a class="xref" href="../../../../../api/Hi.MachiningProcs.RuntimeApi.html#Hi_MachiningProcs_RuntimeApi_StepCount">StepCount</a><small>(API)</small> 取得總步數量。</p>
|
||
<div class="NOTE">
|
||
<h5>Note</h5>
|
||
<p><strong>指令格式</strong></p>
|
||
<pre><code class="lang-csharp">var count = StepCount;
|
||
</code></pre>
|
||
</div>
|
||
<div class="TIP">
|
||
<h5>Tip</h5>
|
||
<p><strong>指令範例</strong></p>
|
||
<pre><code class="lang-csharp">PlayNcFile("NC/file1.nc");
|
||
|
||
// 取得總步數
|
||
var totalSteps = StepCount;
|
||
Message($"Total steps: {totalSteps}");
|
||
|
||
// 遍歷所有步
|
||
for (int i = 0; i < StepCount; i++)
|
||
{
|
||
var step = GetMillingStep(i);
|
||
// 處理步...
|
||
}
|
||
</code></pre>
|
||
</div>
|
||
|
||
</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>
|