如上图,我想获取到这顶层元素的Geometry,请问如何筛选
以下是我的代码,它能够实现获取所有EC属性,但我不知道如何筛选顶层元素的几何属性
ScanCriteria sc = new ScanCriteria(); sc.SetModelRef(Session.Instance.GetActiveDgnModel()); sc.SetModelSections(DgnModelSections.GraphicElements); sc.SetDrawnElements(); DgnModelRef dgnModelRef = Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModelRef(); List<Element> elmtsList = new List<Element>(); ScanDelegate scanDelegate = (Element elmt, DgnModelRef modelRef) => { elmtsList.Add(elmt); return StatusInt.Success; }; sc.Scan(scanDelegate); foreach (Element elmt in elmtsList) { if(elmt == null) { return; } DgnECInstanceCollection dgnECInstanceCollection = DgnECManager.Manager.GetElementProperties(elmt, ECQueryProcessFlags.SearchAllClasses); if (dgnECInstanceCollection == null) { // } foreach (IDgnECInstance inst in dgnECInstanceCollection) { if (inst == null) { // } count++; foreach(var propertyValue in inst) { string strVal; double dblVal; int intVal; if (propertyValue.TryGetStringValue(out strVal)) { string content = "\tProperty=" +"value=" + strVal; } else if (propertyValue.TryGetDoubleValue(out dblVal)) { string content = "\tProperty=" + ", Value=" + dblVal; } else if (propertyValue.TryGetIntValue(out intVal)) { string content = "\tProperty=" + ", Value=" + intVal; } }
只要GetElementProperties的参数传递的是最顶层的单元头元素,读取出来的就都是最顶层的元素的属性,有时候可能读取到的会比元素属性框中看到的多,是因为有些属性没有在元素属性框中显示出来。
MS学习资源:
MicroStation Wednesday视频分享
深入探讨MicroStation DGN基本概念系列
一步步学习MicroStation CE Addin开发
一步步学习MicroStation CE MDL开发