Пример #1
0
        public void IncrementAttribute(BlockTableRecord TableRecord, int index, string prefix, string suffix)
        {
            string           startValue = this.dlg.StartValue;
            int              num        = 0;
            Stack <ObjectId> objectIds  = new Stack <ObjectId>();
            Stack <string>   strs       = new Stack <string>();

            while (true)
            {
                using (BlockReference blockRef = new BlockReference(Point3d.Origin, TableRecord.ObjectId))
                {
                    blockRef.Rotation     = this.dlg.BlockRotation;
                    blockRef.ScaleFactors = new Scale3d(this.dlg.BlockScale);
                    blockRef.TransformBy(this.ed.CurrentUserCoordinateSystem);
                    if (blockRef.Annotative == AnnotativeStates.True)
                    {
                        ObjectContextCollection contextCollection = this.db.ObjectContextManager.GetContextCollection("ACDB_ANNOTATIONSCALES");
                        Autodesk.AutoCAD.Internal.ObjectContexts.AddContext(blockRef, contextCollection.CurrentContext);
                    }
                    ObjectId objectId = this.db.GetCurrentSpace(OpenMode.ForWrite).Add(blockRef);
                    blockRef.AddAttributeReferences(index, string.Concat(prefix, startValue, suffix));
                    BlockJig     blockJig     = new BlockJig(blockRef, num, TableRecord.GetAttributesTextInfos());
                    PromptResult promptResult = this.ed.Drag(blockJig);
                    if (promptResult.Status == PromptStatus.Keyword)
                    {
                        blockRef.Erase();
                        if (num != 0)
                        {
                            objectIds.Pop().GetObject <BlockReference>(OpenMode.ForWrite).Erase();
                            this.db.TransactionManager.QueueForGraphicsFlush();
                            startValue = strs.Pop();
                            num--;
                        }
                        else
                        {
                            this.ed.WriteMessage("\nNothing to undo !");
                        }
                    }
                    else if (promptResult.Status == PromptStatus.OK)
                    {
                        this.db.TransactionManager.QueueForGraphicsFlush();
                        strs.Push(startValue);
                        objectIds.Push(objectId);
                        startValue = this.Increment(startValue);
                        num++;
                    }
                    else
                    {
                        blockRef.Erase();
                        break;
                    }
                }
            }
            this.dlg.txtValue.Text = startValue;
        }