This commit is contained in:
parent
3084db3e86
commit
7263881497
92
Class1.cs
92
Class1.cs
|
@ -3,53 +3,59 @@ using BITKit;
|
||||||
using BITKit.CommandPattern;
|
using BITKit.CommandPattern;
|
||||||
using BITKit.Mod;
|
using BITKit.Mod;
|
||||||
|
|
||||||
namespace com.ifactory.cutting.mode.auto_save_images;
|
namespace BITFactory.Cutting
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 该程序将自动保存导出的数据到同级目录下
|
|
||||||
/// </summary>
|
|
||||||
public sealed class AutoSaveImage:MyMod
|
|
||||||
{
|
{
|
||||||
public override string PackageName { get; set; } = "iFactory.Cutting.Mod.auto_save_images";
|
|
||||||
public override string Name { get; set; } = "自动保存导出数据";
|
|
||||||
|
|
||||||
[Inject] private ICuttingTool _cuttingTool;
|
|
||||||
public override void OnInitialized()
|
|
||||||
{
|
|
||||||
base.OnInitialized();
|
|
||||||
_cuttingTool.OnRelease += OnRelease;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnDisposed()
|
/// <summary>
|
||||||
|
/// 该程序将自动保存导出的数据到同级目录下
|
||||||
|
/// </summary>
|
||||||
|
public sealed class AutoSaveImage : MyMod
|
||||||
{
|
{
|
||||||
base.OnDisposed();
|
public override string PackageName { get; set; } = "iFactory.Cutting.Mod.auto_save_images";
|
||||||
_cuttingTool.OnRelease -= OnRelease;
|
public override string Name { get; set; } = "自动保存导出数据";
|
||||||
}
|
|
||||||
|
[Inject] private ICuttingTool _cuttingTool;
|
||||||
private void OnRelease(ICommand[] obj)
|
|
||||||
{
|
public override void OnInitialized()
|
||||||
var commands = obj.OfType<ICuttingCommand>();
|
|
||||||
var stringBuilder = new System.Text.StringBuilder();
|
|
||||||
var path = Path.Combine(FolderPath,$"export_{DateTime.Now.Ticks}.cfg");
|
|
||||||
stringBuilder.AppendLine($"导出时间: {DateTime.Now}");
|
|
||||||
foreach (var x in commands)
|
|
||||||
{
|
{
|
||||||
switch (x)
|
base.OnInitialized();
|
||||||
{
|
_cuttingTool.OnRelease += OnRelease;
|
||||||
case CuttingPointCommand pointCommand:
|
}
|
||||||
stringBuilder.AppendLine($"切削点: {pointCommand.PlanePoint.x} {pointCommand.PlanePoint.y} {pointCommand.PlanePoint.z}");
|
|
||||||
break;
|
public override void OnDisposed()
|
||||||
case CuttingLineCommand lineCommand:
|
{
|
||||||
stringBuilder.AppendLine($"切削线:{lineCommand.Line.Length}");
|
base.OnDisposed();
|
||||||
foreach (var linePos in lineCommand.Line)
|
_cuttingTool.OnRelease -= OnRelease;
|
||||||
{
|
}
|
||||||
stringBuilder.AppendLine($"切削线点: {linePos.x} {linePos.y} {linePos.z}");
|
|
||||||
}
|
private void OnRelease(ICommand[] obj)
|
||||||
break;
|
{
|
||||||
}
|
var commands = obj.OfType<ICuttingCommand>();
|
||||||
|
var stringBuilder = new System.Text.StringBuilder();
|
||||||
|
var path = Path.Combine(FolderPath, $"export_{DateTime.Now.Ticks}.cfg");
|
||||||
|
stringBuilder.AppendLine($"导出时间: {DateTime.Now}");
|
||||||
|
foreach (var x in commands)
|
||||||
|
{
|
||||||
|
switch (x)
|
||||||
|
{
|
||||||
|
case CuttingPointCommand pointCommand:
|
||||||
|
stringBuilder.AppendLine(
|
||||||
|
$"切削点: {pointCommand.PlanePoint.x} {pointCommand.PlanePoint.y} {pointCommand.PlanePoint.z}");
|
||||||
|
break;
|
||||||
|
case CuttingLineCommand lineCommand:
|
||||||
|
stringBuilder.AppendLine($"切削线:{lineCommand.Line.Length}");
|
||||||
|
foreach (var linePos in lineCommand.Line)
|
||||||
|
{
|
||||||
|
stringBuilder.AppendLine($"切削线点: {linePos.x} {linePos.y} {linePos.z}");
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(path, stringBuilder.ToString());
|
||||||
|
|
||||||
|
BIT4Log.Log<AutoSaveImage>($"导出数据已保存到:{path}");
|
||||||
}
|
}
|
||||||
File.WriteAllText(path,stringBuilder.ToString());
|
|
||||||
|
|
||||||
BIT4Log.Log<AutoSaveImage>($"导出数据已保存到:{path}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue