String ct = "bronzeHorse"; String gt = "horseSurf"; // 在当前模型上修复,保留上一轮已经创建和配置的全部曲面。 if (!java.util.Arrays.asList(model.component().tags()).contains(ct)) { throw new IllegalStateException("当前模型缺少 bronzeHorse 组件。"); } if (!java.util.Arrays.asList( model.component(ct).geom().tags()).contains(gt)) { throw new IllegalStateException("当前组件缺少 horseSurf 几何。"); } String[] prefixes = {"hsEll", "hsTube", "hsMane", "hsHair"}; int[] counts = {38, 14, 22, 16}; java.util.List existingTags = java.util.Arrays.asList( model.component(ct).geom(gt).feature().tags()); for (int group = 0; group < prefixes.length; group++) { for (int i = 1; i <= counts[group]; i++) { String tag = prefixes[group] + i; if (!existingTags.contains(tag)) { throw new IllegalStateException( "缺少上一轮曲面节点 " + tag + ",无法完整保留青铜马造型。"); } } } if (!existingTags.contains("fin")) { throw new IllegalStateException("当前几何缺少最终化节点 fin。"); } model.component(ct).label("青铜骏马 · 曲面雕塑"); model.component(ct).geom(gt).label("青铜马参数化曲面"); model.component(ct).geom(gt).lengthUnit("cm"); // 原有曲面坐标已使用 [cm],继续复用原有尺寸和参数表达式。 // 装配保留独立曲面,不进行相交曲面之间的布尔联合。 // 此模型用于雕塑展示,不将重叠曲面视为单一连续实体。 model.component(ct).geom(gt).feature("fin").set("action", "assembly"); model.component(ct).geom(gt).feature("fin").set("imprint", false); model.component(ct).geom(gt).feature("fin").set("createpairs", false); model.component(ct).geom(gt).feature("fin") .label("形成装配 · 保留雕塑曲面"); model.component(ct).geom(gt).run(); // 几何成功构建后,再完成上一轮尚未执行的材料设置。 String mt = "horseBronze"; if (!java.util.Arrays.asList( model.component(ct).material().tags()).contains(mt)) { model.component(ct).material().create(mt, "Common"); } model.component(ct).material(mt).label("青铜 · 铜锡合金"); model.component(ct).material(mt).selection().geom(gt, 2); model.component(ct).material(mt).selection().all(); model.component(ct).material(mt).propertyGroup("def") .set("density", "8800[kg/m^3]"); model.component(ct).material(mt).propertyGroup("def") .set("youngsmodulus", "110[GPa]"); model.component(ct).material(mt).propertyGroup("def") .set("poissonsratio", "0.34"); // 材料颜色使用 family、diffuse 和 customdiffuse 属性。 // 不再使用上一轮的 customcolor 或向 diffuse 写入 RGB 数组。 model.component(ct).material(mt).set("family", "custom"); model.component(ct).material(mt).set("diffuse", "custom"); model.component(ct).material(mt) .set("customdiffuse", new double[]{0.46, 0.29, 0.12}); model.component(ct).material(mt).set("ambient", "custom"); model.component(ct).material(mt) .set("customambient", new double[]{0.23, 0.15, 0.07}); model.component(ct).material(mt).set("specular", "custom"); model.component(ct).material(mt) .set("customspecular", new double[]{0.82, 0.65, 0.36}); model.component(ct).material(mt).set("shininess", 64.0);