voidExtractClipInfo(BlockTableRecord r, Transaction trans) { var layoutId = r.LayoutId; if (layoutId.IsNull) { returnnull; } var layout = (Layout)trans.GetObject(layoutId, OpenMode.ForRead); if (layout.layoutName != null) { // 注意具有布局名的记录不是块定义! returnnull; }
var blockName = r.Name;
int index = -1; foreach (var objId in r) { index += 1; var entity = trans.GetObject(objId, OpenMode.ForRead) as Entity; if (entity is BlockReference br) { if (br.ExtensionDictionary.IsNull) { continue; } var extDict = trans.GetObject( br.ExtensionDictionary, OpenMode.ForRead, true, true) as DBDictionary; if (!extDict.Contains("ACAD_FILTER")) { continue; } var filterDictId = extDict.GetAt("ACAD_FILTER"); var filterDict = trans.GetObject(filterDictId, OpenMode.ForRead) as DBDictionary; if (!filterDict.Contains("SPATIAL")) { continue; } var filterId = filterDict.GetAt("SPATIAL"); var filterObj = trans.GetObject(filterId, OpenMode.ForRead) as SpatialFilter; if (filterObj == null) { continue; } // filterObj 就是当前块 br 的 SpatialFilter 的信息。 } } }