From 65a8cce19e4508370242606c8a7384297d9fac3c Mon Sep 17 00:00:00 2001 From: iamboss Date: Fri, 18 Sep 2026 20:23:25 +0800 Subject: [PATCH] refactor(demos): build the sample machine tools with GeneralXyzabcMachineTool.CreateFromChainCode and set the buckle and axis transformers through the machine Co-Authored-By: Claude Opus 5 (1M context) --- MachineTool/DemoBuildMachineTool.cs | 13 ++++++------- MachineTool/DemoBuildMachineToolWithoutGeometrys.cs | 6 +++--- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/MachineTool/DemoBuildMachineTool.cs b/MachineTool/DemoBuildMachineTool.cs index 5ed259c..6c93ea1 100644 --- a/MachineTool/DemoBuildMachineTool.cs +++ b/MachineTool/DemoBuildMachineTool.cs @@ -39,10 +39,11 @@ namespace Sample.MachineTool /// A configured machine tool model. public static GeneralXyzabcMachineTool GenXyzabcMachineTool() { - CodeXyzabcChain chain = new CodeXyzabcChain("[O][Y][X][C][w];[O][Z][B][S][t]"); - if (chain.ToolBuckleTransformer is StaticTranslation st) + GeneralXyzabcMachineTool dst = GeneralXyzabcMachineTool.CreateFromChainCode( + "[O][Y][X][C][w];[O][Z][B][S][t]"); + if (dst.ToolBuckleTransformer is StaticTranslation st) st.Trans = new Vec3d(-72.40, 72.40, 176.44); - chain.TransformerB.Pivot = new Vec3d(-72.4, -177.4, 225.94); + dst.TransformerB.Pivot = new Vec3d(-72.4, -177.4, 225.94); Dictionary solidMap = new Dictionary() { ["O"] = new Solid(new Stl("MachineTool/base.stl")), @@ -53,10 +54,8 @@ namespace Sample.MachineTool ["C"] = new Solid(new Stl("MachineTool/C.stl")), ["S"] = new Solid(new Stl("MachineTool/spindle.stl")), }; - chain.AnchorToSolid.BuildAnchorToSolid( - chain.Asmb.DescendantAnchors(), solidMap); - - GeneralXyzabcMachineTool dst = new GeneralXyzabcMachineTool(chain); + dst.AnchorToSolid.BuildAnchorToSolid( + dst.Asmb.DescendantAnchors(), solidMap); dst.GenerateCollisionIndexPairs(); return dst; } diff --git a/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs b/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs index d813812..bf9c378 100644 --- a/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs +++ b/MachineTool/DemoBuildMachineToolWithoutGeometrys.cs @@ -20,10 +20,10 @@ public static class DemoBuildMachineToolWithoutGeometrys /// A configured but empty machine tool without solids. public static GeneralXyzabcMachineTool GenEmptyMachineTool() { - CodeXyzabcChain chain = new CodeXyzabcChain("[O][C][w];[O][X][Y][Z][B][S][t]"); - if (chain.ToolBuckleTransformer is StaticTranslation st) + GeneralXyzabcMachineTool xyzabcMachineTool = GeneralXyzabcMachineTool.CreateFromChainCode( + "[O][C][w];[O][X][Y][Z][B][S][t]"); + if (xyzabcMachineTool.ToolBuckleTransformer is StaticTranslation st) st.Trans = new Vec3d(-200, 200, 400); - GeneralXyzabcMachineTool xyzabcMachineTool = new GeneralXyzabcMachineTool(chain); return xyzabcMachineTool; } }