From b27c36acb8c1633d82f12bd274af38a0ce9088dc Mon Sep 17 00:00:00 2001 From: iamboss Date: Fri, 18 Sep 2026 23:46:25 +0800 Subject: [PATCH] refactor(demos): build the fixture and the workpiece with CreateDefault() and set the workpiece-buckle offset on the fixture's branch Co-Authored-By: Claude Opus 5 (1M context) --- .../DemoBuildGeomOnlyMachiningProject.cs | 27 +++++++------- Machining/DemoBuildMachiningProject.cs | 35 ++++++++++--------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/Machining/DemoBuildGeomOnlyMachiningProject.cs b/Machining/DemoBuildGeomOnlyMachiningProject.cs index 4241418..660cd39 100644 --- a/Machining/DemoBuildGeomOnlyMachiningProject.cs +++ b/Machining/DemoBuildGeomOnlyMachiningProject.cs @@ -70,19 +70,22 @@ public static class DemoBuildGeomOnlyMachiningProject }, }; - 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)), - }; + //The fixture topology is free; the default shape has one branch from the + //geometry anchor to each buckle, so the workpiece buckle 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.WorkpieceBuckle).Transformer + = new StaticTranslation(new Vec3d(0, 0, 10)); + localProjectService.Fixture = fixture; - 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)), - }; + //The default shape already leads from the geometry anchor to the fixture + //buckle 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 diff --git a/Machining/DemoBuildMachiningProject.cs b/Machining/DemoBuildMachiningProject.cs index 1912e03..1f591e9 100644 --- a/Machining/DemoBuildMachiningProject.cs +++ b/Machining/DemoBuildMachiningProject.cs @@ -183,25 +183,28 @@ public static class DemoBuildMachiningProject #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)), - }; + //The fixture topology is free; the default shape has one branch from the + //geometry anchor to each buckle, so the workpiece buckle 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.WorkpieceBuckle).Transformer + = new StaticTranslation(new Vec3d(0, 0, 10)); + localProjectService.Fixture = fixture; #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( - "Resource/CuttingParameter", "Al6061T6.default.mp", progress), - WorkpieceMaterial = XFactory.GenByFile( - "Resource/WorkpieceMaterial", "Al6061T6.default.WorkpieceMaterial", progress), - }; + //The default shape already leads from the geometry anchor to the fixture + //buckle 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; + workpiece.CuttingPara = XFactory.GenByFile( + "Resource/CuttingParameter", "Al6061T6.default.mp", progress); + workpiece.WorkpieceMaterial = XFactory.GenByFile( + "Resource/WorkpieceMaterial", "Al6061T6.default.WorkpieceMaterial", progress); + localProjectService.Workpiece = workpiece; #endregion #region ConfigureMachineChain