update ISO coordinate rendering for 3+2axis machine.
This commit is contained in:
parent
809a250c44
commit
96eb6ad050
@ -3,56 +3,55 @@ 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.");
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// Demonstrates exception handling in synchronous code
|
||||
/// </summary>
|
||||
internal static void DemoSynchronousExceptionHandling()
|
||||
{
|
||||
#region Sync_Exception
|
||||
try
|
||||
{
|
||||
// Your code here
|
||||
throw new NotImplementedException("Demo exception");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionUtil.ShowException(ex, null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// Demonstrates exception handling in asynchronous code
|
||||
/// </summary>
|
||||
internal static async Task DemoAsynchronousExceptionHandling()
|
||||
{
|
||||
#region Async_Exception
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// Your async operation here
|
||||
throw new NotImplementedException("Demo async exception");
|
||||
}).ShowIfCatched(null);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Demonstrates normal message handling
|
||||
/// </summary>
|
||||
internal static void DemoNormalMessages()
|
||||
{
|
||||
#region Normal_Messages
|
||||
MessageUtil.ReportMessage("Operation completed successfully.");
|
||||
MessageUtil.ReportWarning("Please check your input.");
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// Demonstrates exception handling in synchronous code
|
||||
/// </summary>
|
||||
internal static void DemoSynchronousExceptionHandling()
|
||||
{
|
||||
#region Sync_Exception
|
||||
try
|
||||
{
|
||||
// Your code here
|
||||
throw new NotImplementedException("Demo exception");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionUtil.ShowException(ex, null);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
/// <summary>
|
||||
/// Demonstrates exception handling in asynchronous code
|
||||
/// </summary>
|
||||
internal static async Task DemoAsynchronousExceptionHandling()
|
||||
{
|
||||
#region Async_Exception
|
||||
await Task.Run(() =>
|
||||
{
|
||||
// Your async operation here
|
||||
throw new NotImplementedException("Demo async exception");
|
||||
}).ShowIfCatched(null);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -13,136 +13,135 @@ 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;
|
||||
#region Demo_UseSessionMessageHost
|
||||
internal static void DemoUseSessionMessageHost(LocalProjectService localProjectService)
|
||||
{
|
||||
SessionProgress sessionMessageHost = localProjectService.SessionProgress;
|
||||
|
||||
SessionMessageHost.FilterFlag filterFlags =
|
||||
SessionMessageHost.FilterFlag.NC |
|
||||
SessionMessageHost.FilterFlag.Progress |
|
||||
SessionMessageHost.FilterFlag.Error;
|
||||
string filterText = null;
|
||||
var filteredSessionMessageList = sessionMessageHost
|
||||
.GetFliteredList(filterFlags, filterText);
|
||||
SessionProgress.FilterFlag filterFlags =
|
||||
SessionProgress.FilterFlag.NC |
|
||||
SessionProgress.FilterFlag.Progress |
|
||||
SessionProgress.FilterFlag.Error;
|
||||
string filterText = null;
|
||||
var filteredSessionMessageList = sessionMessageHost
|
||||
.GetFliteredList(filterFlags, filterText);
|
||||
|
||||
foreach (var sessionMessage in filteredSessionMessageList)
|
||||
{
|
||||
//M.I.: Message Index.
|
||||
Console.Write($"M.I.: {sessionMessage.Index}; Role: {sessionMessage.MessageRoleText}");
|
||||
foreach (var sessionMessage in filteredSessionMessageList)
|
||||
{
|
||||
//M.I.: Message Index.
|
||||
Console.Write($"M.I.: {sessionMessage.Index}; Role: {sessionMessage.MessageRoleText}");
|
||||
|
||||
// For SessionMessageHost.FilterFlag.NC
|
||||
var nc = sessionMessage.DirectInstantSourceCommand;
|
||||
if (nc != null)
|
||||
Console.Write($"Message/NC: {nc.Line}; File: {nc.FilePath}; LineNo: {nc.GetLineNo()}; ");
|
||||
// For SessionMessageHost.FilterFlag.NC
|
||||
var nc = sessionMessage.DirectInstantSourceCommand;
|
||||
if (nc != null)
|
||||
Console.Write($"Message/NC: {nc.Line}; File: {nc.FilePath}; LineNo: {nc.GetLineNo()}; ");
|
||||
|
||||
// For SessionMessageHost.FilterFlag.Progress or Error.
|
||||
var multiTagMessage = sessionMessage.MultiTagMessage;
|
||||
if (multiTagMessage != null)
|
||||
Console.WriteLine($"Message/NC: {multiTagMessage.Message}");
|
||||
var exception = sessionMessage.Exception;
|
||||
if (exception != null)
|
||||
Console.WriteLine($"Message/NC: {exception.Message}");
|
||||
}
|
||||
File.WriteAllLines("output-session-messages.txt",
|
||||
filteredSessionMessageList.Select(m =>
|
||||
$"Msg[{m.Index}][{m.MessageRoleText}]: {m}"));
|
||||
}
|
||||
#endregion
|
||||
// For SessionMessageHost.FilterFlag.Progress or Error.
|
||||
var multiTagMessage = sessionMessage.MultiTagMessage;
|
||||
if (multiTagMessage != null)
|
||||
Console.WriteLine($"Message/NC: {multiTagMessage.Message}");
|
||||
var exception = sessionMessage.Exception;
|
||||
if (exception != null)
|
||||
Console.WriteLine($"Message/NC: {exception.Message}");
|
||||
}
|
||||
File.WriteAllLines("output-session-messages.txt",
|
||||
filteredSessionMessageList.Select(m =>
|
||||
$"Msg[{m.Index}][{m.MessageRoleText}]: {m}"));
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static void DemoUseSessionMessageHost2(LocalProjectService localProjectService)
|
||||
{
|
||||
SessionMessageHost sessionMessageHost = localProjectService.SessionMessageHost;
|
||||
IMachiningChain machiningChain = localProjectService.MachiningChain;
|
||||
internal static void DemoUseSessionMessageHost2(LocalProjectService localProjectService)
|
||||
{
|
||||
SessionProgress sessionMessageHost = localProjectService.SessionProgress;
|
||||
IMachiningChain machiningChain = localProjectService.MachiningChain;
|
||||
|
||||
PresentAttribute mrrPresent = typeof(MachiningStep).GetProperty(nameof(MachiningStep.Mrr_mm3ds)).GetCustomAttribute<PresentAttribute>();
|
||||
string mrrUnit = mrrPresent?.TailUnitString;
|
||||
string mrrFormat = mrrPresent?.DataFormatString;
|
||||
PresentAttribute torquePresent = typeof(MachiningStep).GetProperty(nameof(MachiningStep.AvgAbsTorque_Nm)).GetCustomAttribute<PresentAttribute>();
|
||||
string torqueUnit = torquePresent?.TailUnitString;
|
||||
string torqueFormat = torquePresent?.DataFormatString;
|
||||
PresentAttribute mrrPresent = typeof(MachiningStep).GetProperty(nameof(MachiningStep.Mrr_mm3ds)).GetCustomAttribute<PresentAttribute>();
|
||||
string mrrUnit = mrrPresent?.TailUnitString;
|
||||
string mrrFormat = mrrPresent?.DataFormatString;
|
||||
PresentAttribute torquePresent = typeof(MachiningStep).GetProperty(nameof(MachiningStep.AvgAbsTorque_Nm)).GetCustomAttribute<PresentAttribute>();
|
||||
string torqueUnit = torquePresent?.TailUnitString;
|
||||
string torqueFormat = torquePresent?.DataFormatString;
|
||||
|
||||
SessionMessageHost.FilterFlag filterFlags =
|
||||
SessionMessageHost.FilterFlag.Step |
|
||||
SessionMessageHost.FilterFlag.NC |
|
||||
SessionMessageHost.FilterFlag.Progress |
|
||||
SessionMessageHost.FilterFlag.Error;
|
||||
string filterText = null;
|
||||
var filteredSessionMessageList = sessionMessageHost
|
||||
.GetFliteredList(filterFlags, filterText);
|
||||
SessionProgress.FilterFlag filterFlags =
|
||||
SessionProgress.FilterFlag.Step |
|
||||
SessionProgress.FilterFlag.NC |
|
||||
SessionProgress.FilterFlag.Progress |
|
||||
SessionProgress.FilterFlag.Error;
|
||||
string filterText = null;
|
||||
var filteredSessionMessageList = sessionMessageHost
|
||||
.GetFliteredList(filterFlags, filterText);
|
||||
|
||||
foreach (var sessionMessage in filteredSessionMessageList)
|
||||
{
|
||||
//M.I.: Message Index.
|
||||
Console.Write($"M.I.: {sessionMessage.Index}; Role: {sessionMessage.MessageRoleText}");
|
||||
foreach (var sessionMessage in filteredSessionMessageList)
|
||||
{
|
||||
//M.I.: Message Index.
|
||||
Console.Write($"M.I.: {sessionMessage.Index}; Role: {sessionMessage.MessageRoleText}");
|
||||
|
||||
// For SessionMessageHost.FilterFlag.Step
|
||||
var step = sessionMessage.MachiningStep;
|
||||
if (step != null)
|
||||
{
|
||||
string[] machineCoordinateValueTexts = GetMachineCoordinateValueTexts(step, machiningChain);
|
||||
var machineCoordinatesText = string.Join("; ", Enumerable.Range(0, machiningChain.McCodes.Length)
|
||||
.Select(i => $"MC.{machiningChain.McCodes[i]}: {machineCoordinateValueTexts[i]}"));
|
||||
Console.Write($"Time: {step.AccumulatedTime:G}; MRR = {step.Mrr_mm3ds.ToString(mrrFormat)} {mrrUnit}; Torque = {step.AvgAbsTorque_Nm?.ToString(torqueFormat)} {torqueUnit}; {machineCoordinatesText}; ");
|
||||
var nc_ = sessionMessageHost.GetSourceCommand(sessionMessage);
|
||||
Console.WriteLine($"Message/NC: {nc_.Line}; File: {nc_.FilePath}; LineNo: {nc_.GetLineNo()}");
|
||||
}
|
||||
// For SessionMessageHost.FilterFlag.Step
|
||||
var step = sessionMessage.MachiningStep;
|
||||
if (step != null)
|
||||
{
|
||||
string[] machineCoordinateValueTexts = GetMachineCoordinateValueTexts(step, machiningChain);
|
||||
var machineCoordinatesText = string.Join("; ", Enumerable.Range(0, machiningChain.McCodes.Length)
|
||||
.Select(i => $"MC.{machiningChain.McCodes[i]}: {machineCoordinateValueTexts[i]}"));
|
||||
Console.Write($"Time: {step.AccumulatedTime:G}; MRR = {step.Mrr_mm3ds.ToString(mrrFormat)} {mrrUnit}; Torque = {step.AvgAbsTorque_Nm?.ToString(torqueFormat)} {torqueUnit}; {machineCoordinatesText}; ");
|
||||
var nc_ = sessionMessageHost.GetSourceCommand(sessionMessage);
|
||||
Console.WriteLine($"Message/NC: {nc_.Line}; File: {nc_.FilePath}; LineNo: {nc_.GetLineNo()}");
|
||||
}
|
||||
|
||||
// For SessionMessageHost.FilterFlag.NC
|
||||
var nc = sessionMessage.DirectInstantSourceCommand;
|
||||
if (nc != null)
|
||||
{
|
||||
Console.Write($"Message/NC: {nc.Line}; File: {nc.FilePath}; LineNo: {nc.GetLineNo()}; ");
|
||||
if (nc is HardNcLine ncLine)
|
||||
Console.WriteLine($"T: {ncLine.T}; S: {ncLine.S}; F: {ncLine.F}; NC-Flags: {ncLine.FlagsText}");
|
||||
}
|
||||
// For SessionMessageHost.FilterFlag.NC
|
||||
var nc = sessionMessage.DirectInstantSourceCommand;
|
||||
if (nc != null)
|
||||
{
|
||||
Console.Write($"Message/NC: {nc.Line}; File: {nc.FilePath}; LineNo: {nc.GetLineNo()}; ");
|
||||
if (nc is HardNcLine ncLine)
|
||||
Console.WriteLine($"T: {ncLine.T}; S: {ncLine.S}; F: {ncLine.F}; NC-Flags: {ncLine.FlagsText}");
|
||||
}
|
||||
|
||||
// For SessionMessageHost.FilterFlag.Progress or Error.
|
||||
var multiTagMessage = sessionMessage.MultiTagMessage;
|
||||
if (multiTagMessage != null)
|
||||
Console.WriteLine($"Message/NC: {multiTagMessage.Message}");
|
||||
var exception = sessionMessage.Exception;
|
||||
if (exception != null)
|
||||
Console.WriteLine($"Message/NC: {exception.Message}");
|
||||
}
|
||||
}
|
||||
static string[] GetMachineCoordinateValueTexts(MachiningStep step, IMachiningChain machiningChain)
|
||||
{
|
||||
var mcTransformers = machiningChain.McTransformers;
|
||||
string[] dst = new string[mcTransformers.Length];
|
||||
if (mcTransformers != null)
|
||||
{
|
||||
for (int i = 0; i < mcTransformers.Length; i++)
|
||||
{
|
||||
if (mcTransformers[i] == null)
|
||||
continue;
|
||||
if (mcTransformers[i] is DynamicRotation)
|
||||
dst[i] = MathUtil.ToDeg(step.GetMcValue(i).Value).ToString("F4");
|
||||
else
|
||||
dst[i] = step.GetMcValue(i)?.ToString("F5");
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
#region ShowStepPresent
|
||||
internal static void ShowStepPresent(
|
||||
UserService userEnv, MachiningStep machiningStep)
|
||||
{
|
||||
foreach (var entry in userEnv.DisplayedStepPresentAccessList)
|
||||
{
|
||||
var present = entry.Value.Present;
|
||||
var valueText = string.Format("{0:" + present.DataFormatString + "}", entry.Value.GetValueFunc.Invoke(machiningStep));
|
||||
Console.WriteLine($"{present.ShortName}: {valueText} {present.TailUnitString} ({present.Name} [{entry.Key}])");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
// For SessionMessageHost.FilterFlag.Progress or Error.
|
||||
var multiTagMessage = sessionMessage.MultiTagMessage;
|
||||
if (multiTagMessage != null)
|
||||
Console.WriteLine($"Message/NC: {multiTagMessage.Message}");
|
||||
var exception = sessionMessage.Exception;
|
||||
if (exception != null)
|
||||
Console.WriteLine($"Message/NC: {exception.Message}");
|
||||
}
|
||||
}
|
||||
static string[] GetMachineCoordinateValueTexts(MachiningStep step, IMachiningChain machiningChain)
|
||||
{
|
||||
var mcTransformers = machiningChain.McTransformers;
|
||||
string[] dst = new string[mcTransformers.Length];
|
||||
if (mcTransformers != null)
|
||||
{
|
||||
for (int i = 0; i < mcTransformers.Length; i++)
|
||||
{
|
||||
if (mcTransformers[i] == null)
|
||||
continue;
|
||||
if (mcTransformers[i] is DynamicRotation)
|
||||
dst[i] = MathUtil.ToDeg(step.GetMcValue(i).Value).ToString("F4");
|
||||
else
|
||||
dst[i] = step.GetMcValue(i)?.ToString("F5");
|
||||
}
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
#region ShowStepPresent
|
||||
internal static void ShowStepPresent(
|
||||
UserService userEnv, MachiningStep machiningStep)
|
||||
{
|
||||
foreach (var entry in userEnv.DisplayedStepPresentAccessList)
|
||||
{
|
||||
var present = entry.Value.Present;
|
||||
var valueText = string.Format("{0:" + present.DataFormatString + "}", entry.Value.GetValueFunc.Invoke(machiningStep));
|
||||
Console.WriteLine($"{present.ShortName}: {valueText} {present.TailUnitString} ({present.Name} [{entry.Key}])");
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@ -3,40 +3,38 @@ using System.Collections.Generic;
|
||||
using Hi.Geom;
|
||||
using Hi.Mech.Topo;
|
||||
|
||||
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>
|
||||
/// Generates a collection of geometric objects for demonstration purposes.
|
||||
/// Creates various geometry types including boxes, cylindroids, STL files, and transformed geometries.
|
||||
/// </summary>
|
||||
/// <returns>A list of geometries implementing the IGetStl interface</returns>
|
||||
public static List<IGetStl> GenGeoms()
|
||||
{
|
||||
Box3d box = new Box3d(0, 0, -50, 70, 50, 0);
|
||||
Cylindroid cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
|
||||
new PairZr(20,16),new PairZr(30,16)]);
|
||||
Stl stl = new Stl("geom.stl");
|
||||
StlFile stlFile = new StlFile("geom.stl");
|
||||
TransformationGeom transformationGeom = new TransformationGeom()
|
||||
{
|
||||
Transformer = new GeneralTransform(1,
|
||||
new StaticRotation(new Vec3d(0, 0, 1), MathUtil.ToRad(15), new Vec3d(0, 0, 0)),
|
||||
new StaticTranslation(new Vec3d(0, 0, 0))),
|
||||
Geom = stl
|
||||
};
|
||||
GeomCombination geomCombination = new GeomCombination(stlFile, transformationGeom);
|
||||
return new List<IGetStl>([box, cylindroid, stl, stlFile, transformationGeom]);
|
||||
}
|
||||
}
|
||||
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>
|
||||
/// Generates a collection of geometric objects for demonstration purposes.
|
||||
/// Creates various geometry types including boxes, cylindroids, STL files, and transformed geometries.
|
||||
/// </summary>
|
||||
/// <returns>A list of geometries implementing the IGetStl interface</returns>
|
||||
public static List<IGetStl> GenGeoms()
|
||||
{
|
||||
Box3d box = new Box3d(0, 0, -50, 70, 50, 0);
|
||||
Cylindroid cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
|
||||
new PairZr(20,16),new PairZr(30,16)]);
|
||||
Stl stl = new Stl("geom.stl");
|
||||
StlFile stlFile = new StlFile("geom.stl");
|
||||
TransformationGeom transformationGeom = new TransformationGeom()
|
||||
{
|
||||
Transformer = new GeneralTransform(1,
|
||||
new StaticRotation(new Vec3d(0, 0, 1), MathUtil.ToRad(15), new Vec3d(0, 0, 0)),
|
||||
new StaticTranslation(new Vec3d(0, 0, 0))),
|
||||
Geom = stl
|
||||
};
|
||||
GeomCombination geomCombination = new GeomCombination(stlFile, transformationGeom);
|
||||
return new List<IGetStl>([box, cylindroid, stl, stlFile, transformationGeom]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,28 +1,27 @@
|
||||
using Hi.Geom;
|
||||
using System;
|
||||
|
||||
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
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
#region DocSite.CountBoundingBox
|
||||
Box3d objA = new Box3d(0, 0, 0, 1, 1, 1);
|
||||
Box3d objB = new Box3d(-1, -2, -3, 3, 2, 1);
|
||||
Vec3d objC = new Vec3d(-2, 3, -5);
|
||||
namespace Sample.Geom;
|
||||
|
||||
Box3d boundingbox = new Box3d(objA, objB, objC);
|
||||
Console.WriteLine("boundingbox: " + boundingbox);
|
||||
#endregion
|
||||
}
|
||||
/// <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
|
||||
Box3d objA = new Box3d(0, 0, 0, 1, 1, 1);
|
||||
Box3d objB = new Box3d(-1, -2, -3, 3, 2, 1);
|
||||
Vec3d objC = new Vec3d(-2, 3, -5);
|
||||
|
||||
Box3d boundingbox = new Box3d(objA, objB, objC);
|
||||
Console.WriteLine("boundingbox: " + boundingbox);
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +34,5 @@
|
||||
<ItemGroup Condition="'$(Configuration)'=='Release'">
|
||||
<PackageReference Include="HiNc" Version="3.1.*" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Coloring\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -3,28 +3,27 @@ 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>
|
||||
/// <returns>A configured but empty machine tool without solids.</returns>
|
||||
public static CodeXyzabcMachineTool GenEmptyMachineTool()
|
||||
{
|
||||
CodeXyzabcChain chain = new CodeXyzabcChain("[O][C][w];[O][X][Y][Z][B][S][t]");
|
||||
if (chain.ToolBuckleTransformer is StaticTranslation st)
|
||||
st.Trans = new Vec3d(-200, 200, 400);
|
||||
CodeXyzabcMachineTool xyzabcMachineTool = new CodeXyzabcMachineTool(chain);
|
||||
return xyzabcMachineTool;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Generates an empty machine tool with basic configuration.
|
||||
/// </summary>
|
||||
/// <returns>A configured but empty machine tool without solids.</returns>
|
||||
public static CodeXyzabcMachineTool GenEmptyMachineTool()
|
||||
{
|
||||
CodeXyzabcChain chain = new CodeXyzabcChain("[O][C][w];[O][X][Y][Z][B][S][t]");
|
||||
if (chain.ToolBuckleTransformer is StaticTranslation st)
|
||||
st.Trans = new Vec3d(-200, 200, 400);
|
||||
CodeXyzabcMachineTool xyzabcMachineTool = new CodeXyzabcMachineTool(chain);
|
||||
return xyzabcMachineTool;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,83 +15,82 @@ 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)]),
|
||||
ShaperProfile = new AptProfile(
|
||||
new ColumnApt()
|
||||
{
|
||||
Diameter_mm = 12,
|
||||
FluteHeight_mm = 40
|
||||
})
|
||||
};
|
||||
internal static MillingCutter CreateGeomOnlyMillingCutter()
|
||||
{
|
||||
MillingCutter millingCutter = new MillingCutter()
|
||||
{
|
||||
UpperBeamGeom = new Cylindroid(
|
||||
[new PairZr(40, 6), new PairZr(90, 6)]),
|
||||
ShaperProfile = new AptProfile(
|
||||
new ColumnApt()
|
||||
{
|
||||
Diameter_mm = 12,
|
||||
FluteHeight_mm = 40
|
||||
})
|
||||
};
|
||||
|
||||
return millingCutter;
|
||||
}
|
||||
return millingCutter;
|
||||
}
|
||||
|
||||
static void Main()
|
||||
{
|
||||
LocalApp.AppBegin();
|
||||
LocalProjectService localProjectService = new LocalProjectService();
|
||||
static void Main()
|
||||
{
|
||||
LocalApp.AppBegin();
|
||||
LocalProjectService localProjectService = new LocalProjectService();
|
||||
|
||||
var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj";
|
||||
var projectDirectory = Path.GetDirectoryName(projectPath);
|
||||
Console.WriteLine($"Directory of the New Project: {projectDirectory}");
|
||||
localProjectService.LoadProject(projectPath);
|
||||
MachiningProject machiningProject = localProjectService.MachiningProject;
|
||||
var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj";
|
||||
var projectDirectory = Path.GetDirectoryName(projectPath);
|
||||
Console.WriteLine($"Directory of the New Project: {projectDirectory}");
|
||||
localProjectService.LoadProject(projectPath);
|
||||
MachiningProject machiningProject = localProjectService.MachiningProject;
|
||||
|
||||
CylindroidHolder cylindroidHolder = new CylindroidHolder()
|
||||
{
|
||||
Note = "BT40",
|
||||
Cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
|
||||
new PairZr(20,16),new PairZr(30,16)])
|
||||
};
|
||||
localProjectService.MachiningToolHouse = new MachiningToolHouse()
|
||||
{
|
||||
[1] = new MillingTool()
|
||||
{
|
||||
Note = "T1",
|
||||
PreservedDistanceBetweenFluteAndSpindleNose_mm = 8,
|
||||
Holder = cylindroidHolder,
|
||||
Cutter = CreateGeomOnlyMillingCutter()
|
||||
},
|
||||
};
|
||||
CylindroidHolder cylindroidHolder = new CylindroidHolder()
|
||||
{
|
||||
Note = "BT40",
|
||||
Cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
|
||||
new PairZr(20,16),new PairZr(30,16)])
|
||||
};
|
||||
localProjectService.MachiningToolHouse = new MachiningToolHouse()
|
||||
{
|
||||
[1] = new MillingTool()
|
||||
{
|
||||
Note = "T1",
|
||||
PreservedDistanceBetweenFluteAndSpindleNose_mm = 8,
|
||||
Holder = cylindroidHolder,
|
||||
Cutter = CreateGeomOnlyMillingCutter()
|
||||
},
|
||||
};
|
||||
|
||||
localProjectService.Fixture = new Fixture()
|
||||
{
|
||||
Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)),
|
||||
GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)),
|
||||
};
|
||||
localProjectService.Fixture = new Fixture()
|
||||
{
|
||||
Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)),
|
||||
GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)),
|
||||
};
|
||||
|
||||
localProjectService.Workpiece = new Workpiece()
|
||||
{
|
||||
InitResolution = 0.25,
|
||||
InitGeom = new Box3d(0, 0, -50, 70, 50, 0),
|
||||
IdealGeom = null,
|
||||
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)),
|
||||
};
|
||||
localProjectService.Workpiece = new Workpiece()
|
||||
{
|
||||
InitResolution = 0.25,
|
||||
InitGeom = new Box3d(0, 0, -50, 70, 50, 0),
|
||||
IdealGeom = null,
|
||||
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)),
|
||||
};
|
||||
|
||||
localProjectService.MachiningChain
|
||||
= XFactory.GenByFile<CodeXyzabcMachineTool>(
|
||||
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default);
|
||||
localProjectService.MachiningChainFile = "PMC-B1/PMC-B1.mt";
|
||||
localProjectService.MachiningChain
|
||||
= XFactory.GenByFile<CodeXyzabcMachineTool>(
|
||||
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default);
|
||||
localProjectService.MachiningChainFile = "PMC-B1/PMC-B1.mt";
|
||||
|
||||
localProjectService.SaveProject();
|
||||
localProjectService.SaveProject();
|
||||
|
||||
machiningProject.Dispose();
|
||||
LocalApp.AppEnd();
|
||||
}
|
||||
machiningProject.Dispose();
|
||||
LocalApp.AppEnd();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,199 +18,198 @@ 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
|
||||
CylindroidHolder cylindroidHolder = new CylindroidHolder()
|
||||
{
|
||||
Note = "BT40",
|
||||
Cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
|
||||
new PairZr(20,16),new PairZr(30,16)])
|
||||
};
|
||||
#endregion
|
||||
return cylindroidHolder;
|
||||
}
|
||||
internal static CylindroidHolder CreateCylindroidHolder()
|
||||
{
|
||||
#region ConfigureHolder
|
||||
CylindroidHolder cylindroidHolder = new CylindroidHolder()
|
||||
{
|
||||
Note = "BT40",
|
||||
Cylindroid = new Cylindroid([ new PairZr(0,12),new PairZr(20,12),
|
||||
new PairZr(20,16),new PairZr(30,16)])
|
||||
};
|
||||
#endregion
|
||||
return cylindroidHolder;
|
||||
}
|
||||
|
||||
#region CreateMillingCutter1
|
||||
internal static MillingCutter CreateMillingCutter1()
|
||||
{
|
||||
double diameter_mm = 12;
|
||||
double roundRadius_mm = 0.5;
|
||||
MillingCutter millingCutter = new MillingCutter()
|
||||
{
|
||||
ShaperProfile = new AptProfile(
|
||||
new ColumnApt()
|
||||
{
|
||||
Diameter_mm = diameter_mm,
|
||||
Rc_mm = roundRadius_mm,
|
||||
FluteHeight_mm = 40
|
||||
}),
|
||||
UpperBeamGeom = new ExtendedCylinder(90),
|
||||
InnerBeamProfile = new FluteDependentRatioProfile(),
|
||||
MillingCutterOptLimit = new MillingCutterOptOption(),
|
||||
};
|
||||
//build FluteContourTray property
|
||||
double helixAngle_deg = 50;
|
||||
double radialRakeAngle_deg = 15;
|
||||
double bottomOuterRadius_mm = diameter_mm / 2 - roundRadius_mm;
|
||||
millingCutter.FluteContourTray = new UniformContourTray()
|
||||
{
|
||||
TrackNum = 3,
|
||||
BaselineOneContour = new FluteContour()
|
||||
{
|
||||
BaseSideContour = new ConstHelixSideContour(millingCutter)
|
||||
{
|
||||
Helix_deg = helixAngle_deg,
|
||||
RadialRakeAngle_deg = radialRakeAngle_deg
|
||||
},
|
||||
BaseBottomContour = new SlideBottomContour()
|
||||
{
|
||||
//In most case, helix angle from side equal to rake angle from bottom.
|
||||
AxialRakeAngle_deg = MathUtil.ToDeg(helixAngle_deg),
|
||||
DiskAngle_deg = 1.5,
|
||||
//In most case, rake angle from side equal to eccentric angle from bottom.
|
||||
EccentricAngle_deg = radialRakeAngle_deg,
|
||||
CutterLengthOnBottomProjection_mm = bottomOuterRadius_mm * 0.9,
|
||||
OuterRadius_mm = bottomOuterRadius_mm
|
||||
}
|
||||
}
|
||||
};
|
||||
#region CreateMillingCutter1
|
||||
internal static MillingCutter CreateMillingCutter1()
|
||||
{
|
||||
double diameter_mm = 12;
|
||||
double roundRadius_mm = 0.5;
|
||||
MillingCutter millingCutter = new MillingCutter()
|
||||
{
|
||||
ShaperProfile = new AptProfile(
|
||||
new ColumnApt()
|
||||
{
|
||||
Diameter_mm = diameter_mm,
|
||||
Rc_mm = roundRadius_mm,
|
||||
FluteHeight_mm = 40
|
||||
}),
|
||||
UpperBeamGeom = new ExtendedCylinder(90),
|
||||
InnerBeamProfile = new FluteDependentRatioProfile(),
|
||||
MillingCutterOptLimit = new MillingCutterOptOption(),
|
||||
};
|
||||
//build FluteContourTray property
|
||||
double helixAngle_deg = 50;
|
||||
double radialRakeAngle_deg = 15;
|
||||
double bottomOuterRadius_mm = diameter_mm / 2 - roundRadius_mm;
|
||||
millingCutter.FluteContourTray = new UniformContourTray()
|
||||
{
|
||||
TrackNum = 3,
|
||||
BaselineOneContour = new FluteContour()
|
||||
{
|
||||
BaseSideContour = new ConstHelixSideContour(millingCutter)
|
||||
{
|
||||
Helix_deg = helixAngle_deg,
|
||||
RadialRakeAngle_deg = radialRakeAngle_deg
|
||||
},
|
||||
BaseBottomContour = new SlideBottomContour()
|
||||
{
|
||||
//In most case, helix angle from side equal to rake angle from bottom.
|
||||
AxialRakeAngle_deg = MathUtil.ToDeg(helixAngle_deg),
|
||||
DiskAngle_deg = 1.5,
|
||||
//In most case, rake angle from side equal to eccentric angle from bottom.
|
||||
EccentricAngle_deg = radialRakeAngle_deg,
|
||||
CutterLengthOnBottomProjection_mm = bottomOuterRadius_mm * 0.9,
|
||||
OuterRadius_mm = bottomOuterRadius_mm
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return millingCutter;
|
||||
}
|
||||
#endregion
|
||||
return millingCutter;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region CreateMillingCutter2
|
||||
internal static MillingCutter CreateMillingCutter2()
|
||||
{
|
||||
MillingCutter millingCutter = new MillingCutter()
|
||||
{
|
||||
ShaperProfile = new AptProfile(new ColumnApt()
|
||||
{
|
||||
Diameter_mm = 12,
|
||||
FluteHeight_mm = 40
|
||||
}),
|
||||
UpperBeamGeom = new Cylindroid(
|
||||
[new PairZr(40, 6), new PairZr(90, 6)]),
|
||||
InnerBeamProfile = new FluteDependentRatioProfile(),
|
||||
MillingCutterOptLimit = new MillingCutterOptOption()
|
||||
};
|
||||
#region CreateMillingCutter2
|
||||
internal static MillingCutter CreateMillingCutter2()
|
||||
{
|
||||
MillingCutter millingCutter = new MillingCutter()
|
||||
{
|
||||
ShaperProfile = new AptProfile(new ColumnApt()
|
||||
{
|
||||
Diameter_mm = 12,
|
||||
FluteHeight_mm = 40
|
||||
}),
|
||||
UpperBeamGeom = new Cylindroid(
|
||||
[new PairZr(40, 6), new PairZr(90, 6)]),
|
||||
InnerBeamProfile = new FluteDependentRatioProfile(),
|
||||
MillingCutterOptLimit = new MillingCutterOptOption()
|
||||
};
|
||||
|
||||
//build FluteContourTray property
|
||||
double helixAngle_deg = 50;
|
||||
double radialRakeAngle_deg = 15;
|
||||
millingCutter.FluteContourTray = new UniformContourTray()
|
||||
{
|
||||
TrackNum = 3,
|
||||
BaselineOneContour = new FluteContour()
|
||||
{
|
||||
BaseSideContour = new ConstHelixSideContour(millingCutter)
|
||||
{
|
||||
Helix_deg = helixAngle_deg,
|
||||
RadialRakeAngle_deg = radialRakeAngle_deg
|
||||
},
|
||||
//since no bottom cut, set bottom contour to null.
|
||||
BaseBottomContour = null
|
||||
}
|
||||
};
|
||||
//build FluteContourTray property
|
||||
double helixAngle_deg = 50;
|
||||
double radialRakeAngle_deg = 15;
|
||||
millingCutter.FluteContourTray = new UniformContourTray()
|
||||
{
|
||||
TrackNum = 3,
|
||||
BaselineOneContour = new FluteContour()
|
||||
{
|
||||
BaseSideContour = new ConstHelixSideContour(millingCutter)
|
||||
{
|
||||
Helix_deg = helixAngle_deg,
|
||||
RadialRakeAngle_deg = radialRakeAngle_deg
|
||||
},
|
||||
//since no bottom cut, set bottom contour to null.
|
||||
BaseBottomContour = null
|
||||
}
|
||||
};
|
||||
|
||||
return millingCutter;
|
||||
}
|
||||
#endregion
|
||||
return millingCutter;
|
||||
}
|
||||
#endregion
|
||||
|
||||
internal static CustomSpinningProfile CreateCustomSpinningProfile()
|
||||
{
|
||||
return new CustomSpinningProfile(
|
||||
new Cylindroid(new PairZr(0, 4), new PairZr(50, 4)));
|
||||
}
|
||||
internal static CustomSpinningProfile CreateCustomSpinningProfile()
|
||||
{
|
||||
return new CustomSpinningProfile(
|
||||
new Cylindroid(new PairZr(0, 4), new PairZr(50, 4)));
|
||||
}
|
||||
|
||||
#region TestMethod
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
LocalApp.AppBegin();
|
||||
LocalProjectService localProjectService = new LocalProjectService();
|
||||
#region TestMethod
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
LocalApp.AppBegin();
|
||||
LocalProjectService localProjectService = new LocalProjectService();
|
||||
|
||||
var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj";
|
||||
var projectDirectory = Path.GetDirectoryName(projectPath);
|
||||
Console.WriteLine($"Directory of the New Project: {projectDirectory}");
|
||||
localProjectService.LoadProject(projectPath);
|
||||
MachiningProject machiningProject = localProjectService.MachiningProject;
|
||||
var projectPath = "C:/HiNC-Projects/NewProject/Main.hincproj";
|
||||
var projectDirectory = Path.GetDirectoryName(projectPath);
|
||||
Console.WriteLine($"Directory of the New Project: {projectDirectory}");
|
||||
localProjectService.LoadProject(projectPath);
|
||||
MachiningProject machiningProject = localProjectService.MachiningProject;
|
||||
|
||||
#region ConfigureMachiningToolHouse
|
||||
localProjectService.MachiningToolHouse = new MachiningToolHouse()
|
||||
{
|
||||
[1] = new MillingTool()
|
||||
{
|
||||
Note = "T1",
|
||||
PreservedDistanceBetweenFluteAndSpindleNose_mm = 8,
|
||||
Holder = CreateCylindroidHolder(),
|
||||
Cutter = CreateMillingCutter1()
|
||||
},
|
||||
[2] = new MillingTool()
|
||||
{
|
||||
Note = "T2",
|
||||
PreservedDistanceBetweenFluteAndSpindleNose_mm = 8,
|
||||
Holder = CreateCylindroidHolder(),
|
||||
Cutter = CreateMillingCutter2()
|
||||
},
|
||||
[3] = new MillingTool()
|
||||
{
|
||||
Note = "T3",
|
||||
PreservedDistanceBetweenFluteAndSpindleNose_mm = 8,
|
||||
Holder = CreateCylindroidHolder(),
|
||||
Cutter = CreateMillingCutter1()
|
||||
},
|
||||
};
|
||||
#endregion
|
||||
#region ConfigureMachiningToolHouse
|
||||
localProjectService.MachiningToolHouse = new MachiningToolHouse()
|
||||
{
|
||||
[1] = new MillingTool()
|
||||
{
|
||||
Note = "T1",
|
||||
PreservedDistanceBetweenFluteAndSpindleNose_mm = 8,
|
||||
Holder = CreateCylindroidHolder(),
|
||||
Cutter = CreateMillingCutter1()
|
||||
},
|
||||
[2] = new MillingTool()
|
||||
{
|
||||
Note = "T2",
|
||||
PreservedDistanceBetweenFluteAndSpindleNose_mm = 8,
|
||||
Holder = CreateCylindroidHolder(),
|
||||
Cutter = CreateMillingCutter2()
|
||||
},
|
||||
[3] = new MillingTool()
|
||||
{
|
||||
Note = "T3",
|
||||
PreservedDistanceBetweenFluteAndSpindleNose_mm = 8,
|
||||
Holder = CreateCylindroidHolder(),
|
||||
Cutter = CreateMillingCutter1()
|
||||
},
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region ConfigureFixture
|
||||
localProjectService.Fixture = new Fixture()
|
||||
{
|
||||
Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)),
|
||||
GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)),
|
||||
};
|
||||
#endregion
|
||||
#region ConfigureFixture
|
||||
localProjectService.Fixture = new Fixture()
|
||||
{
|
||||
Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)),
|
||||
GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)),
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region ConfigureWorkpiece
|
||||
localProjectService.Workpiece = new Workpiece()
|
||||
{
|
||||
InitResolution = 0.25,
|
||||
InitGeom = new Box3d(0, 0, -50, 70, 50, 0),
|
||||
IdealGeom = null,
|
||||
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)),
|
||||
CuttingPara = XFactory.GenByFile<ICuttingPara>(
|
||||
"Resource/CuttingParameter", "Al6061T6.mp", GenMode.Default),
|
||||
WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>(
|
||||
"Resource/WorkpieceMaterial", "Al6061T6.WorkpieceMaterial", GenMode.Default),
|
||||
};
|
||||
#endregion
|
||||
#region ConfigureWorkpiece
|
||||
localProjectService.Workpiece = new Workpiece()
|
||||
{
|
||||
InitResolution = 0.25,
|
||||
InitGeom = new Box3d(0, 0, -50, 70, 50, 0),
|
||||
IdealGeom = null,
|
||||
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)),
|
||||
CuttingPara = XFactory.GenByFile<ICuttingPara>(
|
||||
"Resource/CuttingParameter", "Al6061T6.mp", GenMode.Default),
|
||||
WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>(
|
||||
"Resource/WorkpieceMaterial", "Al6061T6.WorkpieceMaterial", GenMode.Default),
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region ConfigureMachineChain
|
||||
localProjectService.MachiningChain
|
||||
= XFactory.GenByFile<CodeXyzabcMachineTool>(
|
||||
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default);
|
||||
#endregion
|
||||
#region ConfigureMachineChain
|
||||
localProjectService.MachiningChain
|
||||
= XFactory.GenByFile<CodeXyzabcMachineTool>(
|
||||
"Resource", "MachineTool/PMC-B1/PMC-B1.mt", GenMode.Default);
|
||||
#endregion
|
||||
|
||||
machiningProject.MakeXmlSourceToFile(projectPath);
|
||||
machiningProject.MakeXmlSourceToFile(projectPath);
|
||||
|
||||
machiningProject.Dispose();
|
||||
LocalApp.AppEnd();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
machiningProject.Dispose();
|
||||
LocalApp.AppEnd();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -5,82 +5,82 @@ 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();
|
||||
LocalProjectService localProjectService = new LocalProjectService();
|
||||
static void Main()
|
||||
{
|
||||
LocalApp.AppBegin();
|
||||
LocalProjectService localProjectService = new LocalProjectService();
|
||||
|
||||
#region ProjectLoading
|
||||
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
|
||||
Console.WriteLine($"Load Project: {projectPath}");
|
||||
localProjectService.LoadProject(projectPath);
|
||||
MachiningProject machiningProject = localProjectService.MachiningProject;
|
||||
#endregion
|
||||
#region ProjectLoading
|
||||
var projectPath = "C:/HiNC-Projects/DemoStandardPath/Main.hincproj";
|
||||
Console.WriteLine($"Load Project: {projectPath}");
|
||||
localProjectService.LoadProject(projectPath);
|
||||
MachiningProject machiningProject = localProjectService.MachiningProject;
|
||||
#endregion
|
||||
|
||||
#region EventHandling
|
||||
Console.WriteLine($"Set message event.");
|
||||
#region EventHandling
|
||||
Console.WriteLine($"Set message event.");
|
||||
|
||||
using StreamWriter writer = new StreamWriter("msg.txt");
|
||||
//show message if something abnormal.
|
||||
localProjectService.SessionMessageHost.CollectionItemAdded += pack =>
|
||||
{
|
||||
if (pack.Tags.Contains(MessageFlag.Warning.ToString()) ||
|
||||
pack.Tags.Contains(MessageFlag.Error.ToString()) ||
|
||||
pack.Tags.Contains(MessageFlag.Exception.ToString()))
|
||||
{
|
||||
var sourceCommand = pack.SourceCommand;
|
||||
using StreamWriter writer = new StreamWriter("msg.txt");
|
||||
//show message if something abnormal.
|
||||
localProjectService.SessionProgress.CollectionItemAdded += pack =>
|
||||
{
|
||||
if (pack.Tags.Contains(MessageFlag.Warning.ToString()) ||
|
||||
pack.Tags.Contains(MessageFlag.Error.ToString()) ||
|
||||
pack.Tags.Contains(MessageFlag.Exception.ToString()))
|
||||
{
|
||||
var sourceCommand = pack.SourceCommand;
|
||||
writer.WriteLine($"{pack.Message} At \"{sourceCommand?.FilePath}\" (Line {sourceCommand?.GetLineNo()}) \"{sourceCommand?.Line}\"");
|
||||
}
|
||||
};
|
||||
Console.WriteLine($"Set machining step event.");
|
||||
//show MRR.
|
||||
localProjectService.RuntimeApi.MachiningStepBuilt += (preStep, curStep) =>
|
||||
{
|
||||
var sourceCommand = curStep.SourceCommand;
|
||||
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}\"");
|
||||
};
|
||||
#endregion
|
||||
}
|
||||
};
|
||||
Console.WriteLine($"Set machining step event.");
|
||||
//show MRR.
|
||||
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 \"{indexedFileLine?.FilePath}\" (Line {indexedFileLine?.GetLineNo()}) \"{indexedFileLine?.Line}\"");
|
||||
};
|
||||
#endregion
|
||||
|
||||
#region MachiningExecution
|
||||
Console.WriteLine($"Reset runtime status.");
|
||||
localProjectService.ResetRuntime();
|
||||
#region MachiningExecution
|
||||
Console.WriteLine($"Reset runtime status.");
|
||||
localProjectService.ResetRuntime();
|
||||
|
||||
Console.WriteLine($"Session begin.");
|
||||
localProjectService.BeginSession();
|
||||
localProjectService.RuntimeApi.MachiningResolution_mm = 1;
|
||||
localProjectService.RuntimeApi.EnableCollisionDetection = true;
|
||||
localProjectService.RuntimeApi.EnablePauseOnFailure = false;
|
||||
localProjectService.RuntimeApi.EnablePhysics = false;
|
||||
//the path from Shell-API is relative by project directory.
|
||||
localProjectService.RuntimeApi.PlayNcFile("NC/side.ptp");
|
||||
localProjectService.RuntimeApi.PlayNcFile("NC/circle.ptp");
|
||||
localProjectService.EndSession();
|
||||
Console.WriteLine($"Session end.");
|
||||
#endregion
|
||||
Console.WriteLine($"Session begin.");
|
||||
localProjectService.BeginSession();
|
||||
localProjectService.RuntimeApi.MachiningResolution_mm = 1;
|
||||
localProjectService.RuntimeApi.EnableCollisionDetection = true;
|
||||
localProjectService.RuntimeApi.EnablePauseOnFailure = false;
|
||||
localProjectService.RuntimeApi.EnablePhysics = false;
|
||||
//the path from Shell-API is relative by project directory.
|
||||
localProjectService.RuntimeApi.PlayNcFile("NC/side.ptp");
|
||||
localProjectService.RuntimeApi.PlayNcFile("NC/circle.ptp");
|
||||
localProjectService.EndSession();
|
||||
Console.WriteLine($"Session end.");
|
||||
#endregion
|
||||
|
||||
#region CleanupResources
|
||||
Console.WriteLine($"Close Project: {projectPath}");
|
||||
machiningProject.Dispose();
|
||||
#region CleanupResources
|
||||
Console.WriteLine($"Close Project: {projectPath}");
|
||||
machiningProject.Dispose();
|
||||
|
||||
LocalApp.AppEnd();
|
||||
LocalApp.AppEnd();
|
||||
|
||||
Console.WriteLine($"Program end.");
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Console.WriteLine($"Program end.");
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user