public static Element TryGetElement(DgnModelRepositoryConnection modelConn, string instanceId) { Element element; DgnECManager.TryGetElementInfo(modelConn, instanceId, out element); return(element); }
public static List <CellHeaderElement> FindSPDSElementsByInstance(DgnModel model) { if (model == null) { throw new ArgumentNullException(); } DgnFile file = model.GetDgnFile(); DgnFileOwner fileOwner = new DgnFileOwner(file); IECSchema Schema = null; { // todo Правильная инициализация схемы: Schema = DgnECManager.Manager?.LocateDeliveredSchema( ECHelper.SCHEMA_NAME, VrnMajor, VrnMinor, SchemaMatchType.LatestCompatible, file); } if (Schema == null) { return(null); } IECClass commonClass = Schema.GetClass(ECCLASS_COMMON_NAME); ECQuery query = new ECQuery(commonClass); var modelConn = DgnModelRepositoryConnection.CreateConnection( new DgnECConnectionOptions(), fileOwner, model); var instColl = DgnECManager.Manager.FindDgnECInstances(modelConn, query); if (instColl == null) { return(null); } List <CellHeaderElement> resList = new List <CellHeaderElement>(); foreach (var item in instColl) { Element element; if (DgnECManager.TryGetElementInfo(modelConn, item.InstanceId, out element)) { if (element is CellHeaderElement) { resList.Add(element as CellHeaderElement); } } } return(resList); }