update ISO coordinate rendering for 3+2axis machine.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user