Пример #1
0
        /// <summary>
        /// Найти элементы библиотеки Microstation в модели по типам
        /// </summary>
        private IEnumerable <Element> GetModelElements(IEnumerable <ElementMicrostationType> includeTypesMicrostation)
        {
            var elementScanCriteria = new ElementScanCriteria();

            elementScanCriteria.ExcludeAllTypes();

            var includeTypes = includeTypesMicrostation?.Select(ConvertingElementMicrostationTypes.ToMsdMicrostation)
                               ?? Enumerable.Empty <MsdElementType>();

            foreach (var msdElementType in includeTypes)
            {
                elementScanCriteria.IncludeType(msdElementType);
            }

            var elementEnumerator = _modelMicrostation.Scan(elementScanCriteria);

            while (elementEnumerator.MoveNext())
            {
                yield return((Element)elementEnumerator.Current);
            }
        }
Пример #2
0
        private void scanRecurse(ModelReference model, ElementScanCriteria criteria,
                                 bool updateImidiatly)
        {
            if (modelsCellsForUpdate_.ContainsKey(model))
            {
                return;
            }

            var cellsToUpdateList = new List <CellElement>();

            foreach (string cellName in new string[]
                     { PenConfigVariables.CellName.Value, PenConfigVariables.CellNameOld.Value })
            {
                criteria.IncludeOnlyCell(cellName);

                ElementEnumerator iter = App.ActiveModelReference.Scan(criteria);
                iter.Reset();
                while (iter.MoveNext())
                {
                    if (!iter.Current.IsCellElement() && !iter.Current.IsCompundCell())
                    {
                        continue;
                    }

                    bool dirty = false;

                    CellElement cell = iter.Current.AsCellElement();

                    if (updateImidiatly && null == checkedCellsForUpdate_.Find(
                            x => x.MdlElementRef() == cell.MdlElementRef()))
                    {
                        continue;
                    }

                    TFFrameListClass frameList = new TFFrameListClass();
                    try
                    {
                        if (cellName.Equals(PenConfigVariables.CellName.Value))
                        {
                            //frameList.InitFromElement(cell);
                            //process(frameList, ref dirty, updateImidiatly);
                        }
                        else if (cellName.Equals(PenConfigVariables.CellNameOld.Value))
                        {
                            processOld(ref cell, ref dirty, updateImidiatly); // CELL
                            frameList.InitFromElement(cell);                  // FRAME
                            processOld(frameList, ref dirty, updateImidiatly);
                        }
                    }
                    catch (Exception ex)
                    {
                        // TODO log exception
                        continue;
                    }

                    if (dirty)
                    {
                        cellFrames_.Add(cell.MdlElementRef(), frameList);
                        cellsToUpdateList.Add(cell);
                    }
                }
            }

            if (cellsToUpdateList.Count > 0)
            {
                modelsCellsForUpdate_.Add(model, cellsToUpdateList);
            }

            foreach (Attachment attachment in model.Attachments)
            {
                if (!attachment.IsActive || !attachment.IsMissingFile || !attachment.IsMissingModel)
                {
                    return;
                }

                ModelReference modelRef =
                    App.MdlGetModelReferenceFromModelRefP(attachment.MdlModelRefP());
                scanRecurse(modelRef, criteria, updateImidiatly);
            }
        }