update ISO coordinate rendering for 3+2axis machine.

This commit is contained in:
iamboss 2026-04-06 15:09:05 +08:00
parent 809a250c44
commit 96eb6ad050
9 changed files with 559 additions and 570 deletions

View File

@ -3,25 +3,25 @@ using System.Threading.Tasks;
using Hi.Common;
using Hi.Common.Messages;
namespace Sample.Common
namespace Sample.Common;
/// <summary>
/// Demonstrates common message and exception handling patterns in HiAPI applications
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Common/DemoMessageAndExceptionHandling.cs)]
/// </remarks>
public static class DemoMessageAndExceptionHandling
{
/// <summary>
/// Demonstrates common message and exception handling patterns in HiAPI applications
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Common/DemoMessageAndExceptionHandling.cs)]
/// </remarks>
public static class DemoMessageAndExceptionHandling
{
/// <summary>
/// Demonstrates normal message handling
/// </summary>
internal static void DemoNormalMessages()
{
#region Normal_Messages
MessageHost.ReportMessage("Operation completed successfully.");
MessageHost.ReportWarning("Please check your input.");
MessageUtil.ReportMessage("Operation completed successfully.");
MessageUtil.ReportWarning("Please check your input.");
#endregion
}
/// <summary>
@ -54,5 +54,4 @@ namespace Sample.Common
}).ShowIfCatched(null);
#endregion
}
}
}

View File

@ -13,23 +13,23 @@ using Hi.Mech;
using Hi.Mech.Topo;
using Hi.Numerical;
namespace Sample.Common
namespace Sample.Common;
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Common/DemoSessionMessage.cs)]
/// </remarks>
public static class DemoSessionMessage
{
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Common/DemoSessionMessage.cs)]
/// </remarks>
public static class DemoSessionMessage
{
#region Demo_UseSessionMessageHost
internal static void DemoUseSessionMessageHost(LocalProjectService localProjectService)
{
SessionMessageHost sessionMessageHost = localProjectService.SessionMessageHost;
SessionProgress sessionMessageHost = localProjectService.SessionProgress;
SessionMessageHost.FilterFlag filterFlags =
SessionMessageHost.FilterFlag.NC |
SessionMessageHost.FilterFlag.Progress |
SessionMessageHost.FilterFlag.Error;
SessionProgress.FilterFlag filterFlags =
SessionProgress.FilterFlag.NC |
SessionProgress.FilterFlag.Progress |
SessionProgress.FilterFlag.Error;
string filterText = null;
var filteredSessionMessageList = sessionMessageHost
.GetFliteredList(filterFlags, filterText);
@ -60,7 +60,7 @@ namespace Sample.Common
internal static void DemoUseSessionMessageHost2(LocalProjectService localProjectService)
{
SessionMessageHost sessionMessageHost = localProjectService.SessionMessageHost;
SessionProgress sessionMessageHost = localProjectService.SessionProgress;
IMachiningChain machiningChain = localProjectService.MachiningChain;
PresentAttribute mrrPresent = typeof(MachiningStep).GetProperty(nameof(MachiningStep.Mrr_mm3ds)).GetCustomAttribute<PresentAttribute>();
@ -70,11 +70,11 @@ namespace Sample.Common
string torqueUnit = torquePresent?.TailUnitString;
string torqueFormat = torquePresent?.DataFormatString;
SessionMessageHost.FilterFlag filterFlags =
SessionMessageHost.FilterFlag.Step |
SessionMessageHost.FilterFlag.NC |
SessionMessageHost.FilterFlag.Progress |
SessionMessageHost.FilterFlag.Error;
SessionProgress.FilterFlag filterFlags =
SessionProgress.FilterFlag.Step |
SessionProgress.FilterFlag.NC |
SessionProgress.FilterFlag.Progress |
SessionProgress.FilterFlag.Error;
string filterText = null;
var filteredSessionMessageList = sessionMessageHost
.GetFliteredList(filterFlags, filterText);
@ -144,5 +144,4 @@ namespace Sample.Common
}
}
#endregion
}
}

View File

@ -3,18 +3,18 @@ using System.Collections.Generic;
using Hi.Geom;
using Hi.Mech.Topo;
namespace Sample.Geom
namespace Sample.Geom;
/// <summary>
/// Demonstrates the creation and manipulation of geometric objects in HiAPI.
/// Shows how to create and transform various geometry types including boxes, cylindroids, and STL files.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoBuildGeom.cs)]
/// </remarks>
public static class DemoBuildGeom
{
/// <summary>
/// Demonstrates the creation and manipulation of geometric objects in HiAPI.
/// Shows how to create and transform various geometry types including boxes, cylindroids, and STL files.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoBuildGeom.cs)]
/// </remarks>
public static class DemoBuildGeom
{
/// <summary>
/// Generates a collection of geometric objects for demonstration purposes.
/// Creates various geometry types including boxes, cylindroids, STL files, and transformed geometries.
@ -37,6 +37,4 @@ namespace Sample.Geom
GeomCombination geomCombination = new GeomCombination(stlFile, transformationGeom);
return new List<IGetStl>([box, cylindroid, stl, stlFile, transformationGeom]);
}
}
}

View File

@ -1,18 +1,18 @@
using Hi.Geom;
using System;
namespace Sample.Geom
namespace Sample.Geom;
/// <summary>
/// Demonstrates how to create and calculate bounding boxes for different geometric objects.
/// Shows the use of Box3d to encompass multiple geometric elements with a single boundary.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoIExpandToBox3d.cs)]
/// </remarks>
public static class DemoIExpandToBox3d
{
/// <summary>
/// Demonstrates how to create and calculate bounding boxes for different geometric objects.
/// Shows the use of Box3d to encompass multiple geometric elements with a single boundary.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Geom/DemoIExpandToBox3d.cs)]
/// </remarks>
public static class DemoIExpandToBox3d
{
static void Main()
{
#region DocSite.CountBoundingBox
@ -24,5 +24,4 @@ namespace Sample.Geom
Console.WriteLine("boundingbox: " + boundingbox);
#endregion
}
}
}

View File

@ -34,8 +34,5 @@
<ItemGroup Condition="'$(Configuration)'=='Release'">
<PackageReference Include="HiNc" Version="3.1.*" />
</ItemGroup>
<ItemGroup>
<Folder Include="Coloring\" />
</ItemGroup>
</Project>

View File

@ -3,17 +3,17 @@ using Hi.Mech.Topo;
using Hi.NcMech.Xyzabc;
using Hi.Numerical.Xyzabc;
namespace Sample.MachineTool
namespace Sample.MachineTool;
/// <summary>
/// Demo Build Machine Tool without gemetries setting.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs)]
/// </remarks>
public static class DemoBuildMachineToolWithoutGeometrys
{
/// <summary>
/// Demo Build Machine Tool without gemetries setting.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs)]
/// </remarks>
public static class DemoBuildMachineToolWithoutGeometrys
{
/// <summary>
/// Generates an empty machine tool with basic configuration.
/// </summary>
@ -26,5 +26,4 @@ namespace Sample.MachineTool
CodeXyzabcMachineTool xyzabcMachineTool = new CodeXyzabcMachineTool(chain);
return xyzabcMachineTool;
}
}
}

View File

@ -15,20 +15,20 @@ using Hi.Machining;
using Hi.HiNcKits;
using Hi.Milling.MillingTools;
namespace Sample.Machining
namespace Sample.Machining;
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoBuildGeomOnlyMachiningProject.cs)]
/// </remarks>
public static class DemoBuildGeomOnlyMachiningProject
{
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoBuildGeomOnlyMachiningProject.cs)]
/// </remarks>
public static class DemoBuildGeomOnlyMachiningProject
{
internal static MillingCutter CreateGeomOnlyMillingCutter()
{
MillingCutter millingCutter = new MillingCutter()
{
UpperBeamGeom = new Cylindroid(
[new PairZr(40,6), new PairZr(90,6)]),
[new PairZr(40, 6), new PairZr(90, 6)]),
ShaperProfile = new AptProfile(
new ColumnApt()
{
@ -93,5 +93,4 @@ namespace Sample.Machining
LocalApp.AppEnd();
}
}
}

View File

@ -18,20 +18,20 @@ using System.IO;
using Hi.HiNcKits;
using Hi.Milling.MillingTools;
namespace Sample.Machining
namespace Sample.Machining;
/// <summary>
/// Demonstrates how to create and configure a <see cref="MachiningProject"/> programmatically.
/// This sample shows how to set up <see cref="MillingCutter"/>, <see cref="CylindroidHolder"/>,
/// <see cref="MillingTool"/>, <see cref="Fixture"/>, <see cref="Workpiece"/>,
/// and save the project configuration to a file.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoBuildMachiningProject.cs)]
/// </remarks>
public static class DemoBuildMachiningProject
{
/// <summary>
/// Demonstrates how to create and configure a <see cref="MachiningProject"/> programmatically.
/// This sample shows how to set up <see cref="MillingCutter"/>, <see cref="CylindroidHolder"/>,
/// <see cref="MillingTool"/>, <see cref="Fixture"/>, <see cref="Workpiece"/>,
/// and save the project configuration to a file.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoBuildMachiningProject.cs)]
/// </remarks>
public static class DemoBuildMachiningProject
{
internal static CylindroidHolder CreateCylindroidHolder()
{
#region ConfigureHolder
@ -212,5 +212,4 @@ namespace Sample.Machining
LocalApp.AppEnd();
}
#endregion
}
}

View File

@ -5,20 +5,20 @@ using Hi.MachiningProcs;
using System;
using System.IO;
namespace Sample.Machining
namespace Sample.Machining;
/// <summary>
/// Demonstrates how to load and use an existing <see cref="MachiningProject"/> instance.
/// This sample shows how to set up event handlers for messages and machining step objects,
/// execute NC files, and properly manage project resources using
/// <see cref="IDisposable.Dispose"/>.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoUseMachiningProject.cs)]
/// </remarks>
public static class DemoUseMachiningProject
{
/// <summary>
/// Demonstrates how to load and use an existing <see cref="MachiningProject"/> instance.
/// This sample shows how to set up event handlers for messages and machining step objects,
/// execute NC files, and properly manage project resources using
/// <see cref="IDisposable.Dispose"/>.
/// </summary>
/// <remarks>
/// ### Source Code
/// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoUseMachiningProject.cs)]
/// </remarks>
public static class DemoUseMachiningProject
{
static void Main()
{
LocalApp.AppBegin();
@ -36,7 +36,7 @@ namespace Sample.Machining
using StreamWriter writer = new StreamWriter("msg.txt");
//show message if something abnormal.
localProjectService.SessionMessageHost.CollectionItemAdded += pack =>
localProjectService.SessionProgress.CollectionItemAdded += pack =>
{
if (pack.Tags.Contains(MessageFlag.Warning.ToString()) ||
pack.Tags.Contains(MessageFlag.Error.ToString()) ||
@ -51,8 +51,9 @@ namespace Sample.Machining
localProjectService.RuntimeApi.MachiningStepBuilt += (preStep, curStep) =>
{
var sourceCommand = curStep.SourceCommand;
var indexedFileLine=sourceCommand?.GetSentence()?.IndexedFileLine;
if (curStep.Mrr_mm3ds > 500) //show only the step that contains large MRR.
Console.WriteLine($"MRR = {curStep.Mrr_mm3ds} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
Console.WriteLine($"MRR = {curStep.Mrr_mm3ds} At \"{indexedFileLine?.FilePath}\" (Line {indexedFileLine?.GetLineNo()}) \"{indexedFileLine?.Line}\"");
};
#endregion
@ -82,5 +83,4 @@ namespace Sample.Machining
Console.WriteLine($"Program end.");
#endregion
}
}
}