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()
{
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<object> progress = null;
localProjectService.MachiningChain
+19 -16
View File
@@ -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<ICuttingPara>(
"Resource/CuttingParameter", "Al6061T6.default.mp", progress),
WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>(
"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<ICuttingPara>(
"Resource/CuttingParameter", "Al6061T6.default.mp", progress);
workpiece.WorkpieceMaterial = XFactory.GenByFile<WorkpieceMaterial>(
"Resource/WorkpieceMaterial", "Al6061T6.default.WorkpieceMaterial", progress);
localProjectService.Workpiece = workpiece;
#endregion
#region ConfigureMachineChain