using Hi.Common.XmlUtils; using Hi.Geom; using Hi.MachiningProcs; using Hi.Mech.Topo; using Hi.Milling.Apts; using Hi.Milling.Cutters; using Hi.NcMech.Fixtures; using Hi.NcMech.Workpieces; using Hi.NcMech.Xyzabc; using System.Collections.Generic; using System.IO; using System; using Hi.NcMech.Holders; using Hi.Machining; using Hi.HiNcKits; using Hi.Milling.MillingTools; using Microsoft.Extensions.Logging; namespace Sample.Machining; /// /// ### Source Code /// [!code-csharp[SampleCode](~/../Hi.Sample/Machining/DemoBuildGeomOnlyMachiningProject.cs)] /// 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 }) }; return millingCutter; } static void Main() { using var loggerFactory = Microsoft.Extensions.Logging.LoggerFactory.Create(b => b.AddConsole()); LocalApp.AppBegin(loggerFactory.CreateLogger("Hi.Sample")); 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; 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() }, }; //The fixture topology is free; the default shape has one branch from the //geometry anchor to each mount, so the workpiece mount is placed by the //transformer of the branch to it: on top of the 10 mm thick fixture geom. Fixture fixture = Fixture.CreateDefault(); fixture.Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)); Branch.Get(fixture.GeomAnchor, fixture.WorkpieceMount).Transformer = new StaticTranslation(new Vec3d(0, 0, 10)); localProjectService.Fixture = fixture; //The default shape already leads from the geometry anchor to the fixture //mount and to program zero by zero translations. Workpiece workpiece = Workpiece.CreateDefault(); workpiece.InitResolution = 0.25; workpiece.InitGeom = new Box3d(0, 0, -50, 70, 50, 0); workpiece.IdealGeom = null; localProjectService.Workpiece = workpiece; IProgress progress = null; localProjectService.MachiningChain = XFactory.GenByFile( "Resource", "MachineTool/Table-B1.default/Table-B1.mt", progress); localProjectService.MachiningChainFile = "Table-B1.default/Table-B1.mt"; localProjectService.SaveProject(); machiningProject.Dispose(); LocalApp.AppEnd(); } }