一、 概述
AVEVA 12.1支持CSG接口用于输出几何模型数据。
二、 示例代码
1 DbElement ce = CurrentElement.Element; 2 Aveva.Pdms.CSG.Implementation.CSGTreeBuilderImpl.Init(); 3 Aveva.Pdms.CSG.Implementation.CSGTreeBuilderOptionsImpl op = (Aveva.Pdms.CSG.Implementation.CSGTreeBuilderOptionsImpl)Aveva.Pdms.CSG.Implementation.CSGTreeBuilderImpl.Instance.CreateCSGTreeBuilderOptions(); 4 op.CenterLine = false; 5 op.Holes = false; 6 op.Level = 6; 7 op.SolidOnly = true; 8 op.Tube = true; 9 CSGTree[] tree = Aveva.Pdms.CSG.Implementation.CSGTreeBuilderImpl.Instance.GetGeometry(ce, op);10 for (int a = 0; a < tree.Length; a++)11 {12 for (int b = 0; b < tree[a].Items.Length; b++)13 {14 string Command;15 Aveva.Pdms.Utilities.CommandLine.Command cmd;16 switch (tree[a].Items[b].Type)17 {18 case CSGType.CSG_BOX:19 CSGBox box = tree[a].Items[b] as CSGBox;20 double x = box.XLength;21 double y = box.YLength;22 double z = box.ZLength;23 System.Console.WriteLine("CSGBox x:{0} y:{1} z:{2}", x, y, z);24 break;25 case CSGType.CSG_CYLI:26 CSGCylinder cylinder = tree[a].Items[b] as CSGCylinder;27 double radius = cylinder.Radius;28 double height = cylinder.Height;29 System.Console.WriteLine("CSGCylinder radius:{0} height:{1}", radius, height); 30 break;31 .............................................. 32 .............................................. 33 .............................................. 34 default:35 break;36 }37 38 }39 }
三、总结
通过CSG接口我们可以直接从PDMS中有选择性的抽取PDMS三维模型数据到其他软件。通过编程的方式操作更加灵活,而无需使用rvm格式文件。
特别适合需要做数字化移交时的模型输出开发。