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