Ejemplo n.º 1
0
        private void FixAllCheckResultsWithProgresser(bool updateScreen, string verb, string objectName)
        {
            var checkResults = new List <CheckResult>();

            foreach (var checkResultGroup in CheckResultGroups)
            {
                checkResults.AddRange(checkResultGroup.Value.CheckResults);
            }

            var promptText = String.Format("正在{0}{1}中...", verb, objectName);

            using (var progresser = new SimpleLongOperationManager(promptText))
            {
                progresser.SetTotalOperations(checkResults.Count);
                foreach (var checkresult in checkResults)
                {
                    FixCheckResult(checkresult, updateScreen: false);
                    progresser.Tick();
                }
            }

            // Udpate screen
            if (updateScreen)
            {
                Document.Editor.UpdateScreen();
            }
        }
Ejemplo n.º 2
0
        protected override bool CheckAndFixAllImpl(IEnumerable <ObjectId> ids)
        {
            var editor   = Document.Editor;
            var database = Document.Database;

            // Check
            editor.WriteMessage("\n开始检查高程不为0对象...");
            var elevationIds = new List <ObjectId>();

            using (var transaction = database.TransactionManager.StartTransaction())
            {
                var modelspace = (BlockTableRecord)transaction.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(database), OpenMode.ForRead);
                foreach (ObjectId objectId in modelspace)
                {
                    if (CurveUtils.IsCurveNonZeroElevation(objectId, transaction))
                    {
                        elevationIds.Add(objectId);
                    }
                }
                transaction.Commit();
            }

            // Fix
            if (elevationIds.Count <= 0)
            {
                editor.WriteMessage("\n检测到0个对象,无需修复\n");
                return(false);
            }

            // Ask whether to fix.
            var message = String.Format("\n检测到{0}个对象,是否修复?", elevationIds.Count);

            if (!AskContinueFix(message, editor))
            {
                return(false);
            }

            var failedIds = new List <ObjectId>();

            using (var transaction = database.TransactionManager.StartTransaction())
            {
                using (var progresser = new SimpleLongOperationManager(String.Empty))
                {
                    progresser.SetTotalOperations(elevationIds.Count);
                    foreach (ObjectId elevationId in elevationIds)
                    {
                        var result = CurveUtils.SetCurveElevationToZero(transaction, elevationId);
                        if (!result)
                        {
                            failedIds.Add(elevationId);
                        }
                        progresser.Tick();
                    }
                }
                transaction.Commit();
            }

            editor.WriteMessage("\n修复完毕:成功{0}个,失败{1}个\n", elevationIds.Count - failedIds.Count, failedIds.Count);
            return(true);
        }