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) <noreply@anthropic.com>
This commit is contained in:
2026-09-18 23:46:25 +08:00
co-authored by Claude Opus 5
parent 65a8cce19e
commit b27c36acb8
2 changed files with 34 additions and 28 deletions
+15 -12
View File
@@ -70,19 +70,22 @@ public static class DemoBuildGeomOnlyMachiningProject
}, },
}; };
localProjectService.Fixture = new Fixture() //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
Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)), //transformer of the branch to it: on top of the 10 mm thick fixture geom.
GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)), 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() //The default shape already leads from the geometry anchor to the fixture
{ //buckle and to program zero by zero translations.
InitResolution = 0.25, Workpiece workpiece = Workpiece.CreateDefault();
InitGeom = new Box3d(0, 0, -50, 70, 50, 0), workpiece.InitResolution = 0.25;
IdealGeom = null, workpiece.InitGeom = new Box3d(0, 0, -50, 70, 50, 0);
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)), workpiece.IdealGeom = null;
}; localProjectService.Workpiece = workpiece;
IProgress<object> progress = null; IProgress<object> progress = null;
localProjectService.MachiningChain localProjectService.MachiningChain
+19 -16
View File
@@ -183,25 +183,28 @@ public static class DemoBuildMachiningProject
#endregion #endregion
#region ConfigureFixture #region ConfigureFixture
localProjectService.Fixture = new Fixture() //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
Geom = new Box3d(new Vec3d(-40, -40, 0), new Vec3d(40, 40, 10)), //transformer of the branch to it: on top of the 10 mm thick fixture geom.
GeomToWorkpieceTransformer = new StaticTranslation(new Vec3d(0, 0, 10)), 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 #endregion
#region ConfigureWorkpiece #region ConfigureWorkpiece
localProjectService.Workpiece = new Workpiece() //The default shape already leads from the geometry anchor to the fixture
{ //buckle and to program zero by zero translations.
InitResolution = 0.25, Workpiece workpiece = Workpiece.CreateDefault();
InitGeom = new Box3d(0, 0, -50, 70, 50, 0), workpiece.InitResolution = 0.25;
IdealGeom = null, workpiece.InitGeom = new Box3d(0, 0, -50, 70, 50, 0);
WorkpieceGeomToFixtureBuckleTransformer = new StaticTranslation(new Vec3d(0, 0, 0)), workpiece.IdealGeom = null;
CuttingPara = XFactory.GenByFile<ICuttingPara>( workpiece.CuttingPara = XFactory.GenByFile<ICuttingPara>(
"Resource/CuttingParameter", "Al6061T6.default.mp", progress), "Resource/CuttingParameter", "Al6061T6.default.mp", progress);
WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>( workpiece.WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>(
"Resource/WorkpieceMaterial", "Al6061T6.default.WorkpieceMaterial", progress), "Resource/WorkpieceMaterial", "Al6061T6.default.WorkpieceMaterial", progress);
}; localProjectService.Workpiece = workpiece;
#endregion #endregion
#region ConfigureMachineChain #region ConfigureMachineChain