Esempio n. 1
0
        public static void RemoveDimStyle(string dimStyleName)
        {
            Database database = Active.Database;

            try
            {
                DimStyleTable dimStyleTable = GetDimStyleTable();
                using (Transaction transaction = database.TransactionManager.StartTransaction())
                {
                    foreach (ObjectId dimStyleTableRecordId in dimStyleTable)
                    {
                        DimStyleTableRecord dimStyleTableRecord = transaction.GetObject <DimStyleTableRecord>(dimStyleTableRecordId, OpenMode.ForRead);
                        if (dimStyleTableRecord.Name == dimStyleName)
                        {
                            dimStyleTableRecord.UpgradeOpen();
                            dimStyleTableRecord.Erase();
                        }
                    }

                    transaction.Commit();
                }//using
            }
            catch (Exception ex)
            {
                Active.WriteMessage(ex.Message);
                throw;
            }
        }
Esempio n. 2
0
        getDimStyleTableRecord(string name)
        {
            ObjectId id = ObjectId.Null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    DimStyleTable dst = (DimStyleTable)HostApplicationServices.WorkingDatabase.DimStyleTableId.GetObject(OpenMode.ForRead);
                    if (dst.Has(name) == true)
                    {
                        //dst.UpgradeOpen();
                        DimStyleTableRecord dstr = (DimStyleTableRecord)dst[name].GetObject(OpenMode.ForRead);
                        id = dstr.ObjectId;
                    }
                    else
                    {
                        dst.UpgradeOpen();
                        DimStyleTableRecord dstr = new DimStyleTableRecord();
                        dstr.Name       = name;
                        dstr.Annotative = AnnotativeStates.True;
                        id = dst.Add(dstr);
                        tr.AddNewlyCreatedDBObject(dstr, true);
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Dim.cs: line: 162");
            }
            return(id);
        }
Esempio n. 3
0
        public void CreatedimStyle()
        {
            string text = Interaction.InputBox("输入标注样式的名称、全局标注比例、测量标注比例,用/分开。", "田草CAD工具箱.Net版", "Dim100/100/1", -1, -1);

            string[] array = new string[3];
            string   s     = text;
            string   text2 = "/";

            NF.Str2Arr(s, ref array, ref text2);
            if (Operators.CompareString(array[0], "", false) != 0)
            {
                string   text3           = array[0];
                int      int_            = Conversions.ToInteger(array[1]);
                double   double_         = Conversions.ToDouble(array[2]);
                Database workingDatabase = HostApplicationServices.WorkingDatabase;
                Editor   editor          = Application.DocumentManager.MdiActiveDocument.Editor;
                using (Transaction transaction = workingDatabase.TransactionManager.StartTransaction())
                {
                    DimStyleTable dimStyleTable = (DimStyleTable)transaction.GetObject(workingDatabase.DimStyleTableId, 1);
                    ObjectId      objectId      = Class36.smethod_78(text3, int_, double_, false);
                    if (objectId != ObjectId.Null)
                    {
                        DimStyleTableRecord dimStyleTableRecord = (DimStyleTableRecord)transaction.GetObject(objectId, 1);
                    }
                    else
                    {
                        editor.WriteMessage("\r标注样式 " + text3 + " 已存在!");
                    }
                    transaction.Commit();
                }
            }
        }
        public void Union(Dictionary <string, ObjectId[]> dicDeleteDimStyles, DimStyleTableRecord[] resultStyleName)
        {
            using (Transaction t = targetDB.TransactionManager.StartTransaction())
            {
                DimStyleTable tblStyle = (DimStyleTable)t.GetObject(targetDB.DimStyleTableId, OpenMode.ForWrite);
                foreach (var _style in dicDeleteDimStyles)
                {
                    foreach (var _x in _style.Value)
                    {
                        DBObject  item = t.GetObject(_x, OpenMode.ForWrite);
                        Dimension y    = (Dimension)item;
                        if (y.Annotative != AnnotativeStates.True)
                        {
                            SetStyleAnnotative(resultStyleName, item, y);
                        }
                        SetStyleByType(resultStyleName, item, y);
                    }


                    if (!CanBeRemoved(_style.Key))
                    {
                        continue;
                    }

                    List <DimStyleTableRecord> dimStyles = tblStyle.Cast <ObjectId>().Select(n => (DimStyleTableRecord)t.GetObject(n, OpenMode.ForWrite, true)).ToList();
                    DimStyleTableRecord        styleDel  = dimStyles.Select(x => x).Where(x => x.Name.ToUpper().Equals(_style.Key)).ToList()[0];
                    styleDel.Erase();
                }
                t.Commit();
            }
        }
Esempio n. 5
0
        public static DimStyleTableRecord GetDimStyle(string styleName)
        {
            Document document = Active.Document;
            Database database = document.Database;

            using (Transaction transaction = database.TransactionManager.StartTransaction())
            {
                try
                {
                    DimStyleTable dimStyleTable = GetDimStyleTable();
                    foreach (ObjectId dimStyleTableRecordId in dimStyleTable)
                    {
                        DimStyleTableRecord dimStyleTableRecord = transaction.GetObject <DimStyleTableRecord>(dimStyleTableRecordId, OpenMode.ForRead);
                        if (dimStyleTableRecord.Name == styleName)
                        {
                            return(dimStyleTableRecord);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Active.WriteMessage(ex.Message);
                    throw;
                }
            }// using
            return(null);
        }
 /// <summary>
 /// Gets the dim style table records.
 /// </summary>
 /// <param name="symbolTbl">The symbol table.</param>
 /// <param name="mode">The mode.</param>
 /// <param name="filter">The filter.</param>
 /// <returns></returns>
 public static IEnumerable <DimStyleTableRecord> GetDimStyleTableRecords(this DimStyleTable symbolTbl,
                                                                         OpenMode mode = OpenMode.ForRead, SymbolTableRecordFilter filter = SymbolTableRecordFilter.None)
 {
     return
         (symbolTbl.GetSymbolTableRecords <DimStyleTableRecord>(
              symbolTbl.Database.TransactionManager.TopTransaction, mode, filter, true));
 }
Esempio n. 7
0
 public void DimStyleTableTrx()
 {
     using (Transaction trx = Db.TransactionManager.StartTransaction())
     {
         DimStyleTable dt = Db.DimStyleTable(trx);
         Ed.WriteLine(dt.ObjectId);
     }
 }
Esempio n. 8
0
        static public ObjectIdCollection GetObjIdNonGrafical(Database db)
        {
            ObjectIdCollection idsNonGraficals = new ObjectIdCollection();

            Transaction tr = db.TransactionManager.StartTransaction();

            using (tr)
            {
                //Block Table
                BlockTable btBlock = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                foreach (ObjectId btrId in btBlock)
                {
                    idsNonGraficals.Add(btrId);
                }

                //Dim Style
                DimStyleTable tbDimSty = tr.GetObject(db.DimStyleTableId, OpenMode.ForRead) as DimStyleTable;
                foreach (ObjectId btrId in tbDimSty)
                {
                    idsNonGraficals.Add(btrId);
                }

                //Layer
                LayerTable tbLayer = tr.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
                foreach (ObjectId btrId in tbLayer)
                {
                    idsNonGraficals.Add(btrId);
                }

                //Line types
                LinetypeTable tbLinetype = tr.GetObject(db.LinetypeTableId, OpenMode.ForRead) as LinetypeTable;
                foreach (ObjectId btrId in tbLinetype)
                {
                    idsNonGraficals.Add(btrId);
                }

                //Table Style
                TextStyleTable tbTextStyle = tr.GetObject(db.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
                foreach (ObjectId btrId in tbTextStyle)
                {
                    idsNonGraficals.Add(btrId);
                }

                foreach (ObjectId objId in idsNonGraficals)
                {
                    if (!objId.IsValid)
                    {
                        idsNonGraficals.Remove(objId);
                    }
                }
            }

            return(idsNonGraficals);
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            this.Hide();

            string message;

            if (checkBox1.Checked == true)
            {
                PublicValue.dimScale    = double.Parse(textBox1.Text);
                PublicValue.scaleFactor = double.Parse(textBox2.Text) / PublicValue.dimScale;
                string dimStyleName = "BF" + textBox1.Text + "-" + textBox2.Text;

                using (Transaction trans = PublicValue.acDb.TransactionManager.StartTransaction())
                {
                    DimStyleTable dst = (DimStyleTable)trans.GetObject(PublicValue.acDb.DimStyleTableId, OpenMode.ForRead);
                    if (!dst.Has(dimStyleName))
                    {
                        DimStyleTools.CreateModifyDimStyle(dimStyleName, out message);
                        DimStyleTools.SetCurrentDimStyle(dimStyleName);
                        StatusBars.UpdateAppPane();
                    }
                    else
                    {
                        DimStyleTools.SetCurrentDimStyle(dimStyleName);
                        StatusBars.UpdateAppPane();
                    }
                }
            }
            else
            {
                PublicValue.dimScale = double.Parse(textBox1.Text);
                string dimStyleName = "BF" + textBox1.Text;
                PublicValue.scaleFactor = 1.0;
                using (Transaction trans = PublicValue.acDb.TransactionManager.StartTransaction())
                {
                    DimStyleTable dst = (DimStyleTable)trans.GetObject(PublicValue.acDb.DimStyleTableId, OpenMode.ForRead);
                    if (!dst.Has(dimStyleName))
                    {
                        DimStyleTools.CreateModifyDimStyle(dimStyleName, out message);
                        DimStyleTools.SetCurrentDimStyle(dimStyleName);
                        StatusBars.UpdateAppPane();
                    }
                    else
                    {
                        DimStyleTools.SetCurrentDimStyle(dimStyleName);
                        StatusBars.UpdateAppPane();
                    }
                }
            }
            this.Close();
        }
        private void CopyEtalonStyle(ObjectIdCollection col)
        {
            IdMapping acIdMap = new IdMapping();

            using (Transaction t = targetDB.TransactionManager.StartTransaction())
            {
                DimStyleTable tst = (DimStyleTable)t.GetObject(targetDB.DimStyleTableId, OpenMode.ForRead);
                // ObjectIdCollection col = new ObjectIdCollection();
                // col.Add(pikStyle.ObjectId);

                targetDB.WblockCloneObjects(col, tst.Id, acIdMap, DuplicateRecordCloning.Replace, false);
                t.Commit();
            }
        }
Esempio n. 11
0
 /// <summary>
 /// 获取标注样式ID
 /// </summary>
 /// <param name="dimstyle">样式名</param>
 /// <returns>样式ID</returns>
 public static ObjectId GetDimstyleId(string dimstyle)
 {
     using (Transaction trans = HostApplicationServices.WorkingDatabase.TransactionManager.StartTransaction())
     {
         DimStyleTable dsTable = (DimStyleTable)trans.GetObject(HostApplicationServices.WorkingDatabase.DimStyleTableId, OpenMode.ForRead);
         if (dsTable.Has(dimstyle))
         {
             return(dsTable[dimstyle]);
         }
         else
         {
             return(HostApplicationServices.WorkingDatabase.Dimstyle);
         }
     }
 }
Esempio n. 12
0
        public StringCollection GetDimensionStylesList()
        {
            StringCollection dimStylesCollection = new StringCollection();

            using (Transaction transaction = _db.TransactionManager.StartTransaction())
            {
                DimStyleTable dimStyleTable = (DimStyleTable)transaction.GetObject(_db.DimStyleTableId, OpenMode.ForRead);
                foreach (ObjectId dimStyleTableRecordId in dimStyleTable)
                {
                    DimStyleTableRecord dimStyleTableRecord = (DimStyleTableRecord)transaction.GetObject(dimStyleTableRecordId, OpenMode.ForRead);
                    dimStylesCollection.Add(dimStyleTableRecord.Name);
                }
                transaction.Commit();
            }
            return(dimStylesCollection);
        }
Esempio n. 13
0
        public void netDimAngular()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;
            Editor   ed  = doc.Editor;

            PromptEntityOptions peo = new PromptEntityOptions("\nSelect an Arc: ");

            peo.SetRejectMessage("\nMust be an Arc...");

            peo.AddAllowedClass(typeof(Arc), true);

            PromptEntityResult per = ed.GetEntity(peo);

            if (per.Status != PromptStatus.OK)
            {
                return;
            }

            using (Transaction Tx = db.TransactionManager.StartTransaction())
            {
                Arc arc = Tx.GetObject(per.ObjectId, OpenMode.ForRead) as Arc;

                BlockTable bt = Tx.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;

                BlockTableRecord btr = Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;

                string dimStyle = "Standard";

                DimStyleTable dimStyleTable = Tx.GetObject(db.DimStyleTableId, OpenMode.ForRead) as DimStyleTable;

                if (dimStyleTable.Has(dimStyle))
                {
                    Point3d point3 = arc.StartPoint.Add(arc.EndPoint.GetAsVector()).MultiplyBy(0.5);

                    ObjectId dimStyleId = dimStyleTable[dimStyle];

                    Point3AngularDimension dim = new Point3AngularDimension(arc.Center, arc.StartPoint, arc.EndPoint, point3, "", dimStyleId);

                    btr.AppendEntity(dim);

                    Tx.AddNewlyCreatedDBObject(dim, true);
                    Tx.Commit();
                }
            }
        }
Esempio n. 14
0
        public static bool CheckDimStyleExists(string DimStyleName)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;

            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {
                DimStyleTableRecord dstr = new DimStyleTableRecord();
                DimStyleTable       dst  = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForRead, true);
                if (dst.Has(DimStyleName))
                {
                    return(true);
                }

                return(false);
            }
        }
Esempio n. 15
0
        //public static ObjectId AddDimStyle(this Database db,string styleName)
        //{
        //    DimStyleTable dst = (DimStyleTable)db.DimStyleTableId.GetObject(OpenMode.ForRead);

        //    if (!dst.Has(styleName))
        //    {
        //        DimStyleTableRecord dstr = new DimStyleTableRecord();

        //        dstr.Name = styleName;
        //        dstr.Dimscale = 12;
        //        dst.UpgradeOpen();
        //        dst.Add(dstr);
        //        db.TransactionManager.AddNewlyCreatedDBObject(dstr, true);
        //        dst.DowngradeOpen();
        //    }
        //    return dst[styleName];
        //}

        public static void AddDimStyle(this Database db, string styleName)
        {
            DimStyleTable dst = (DimStyleTable)db.DimStyleTableId.GetObject(OpenMode.ForRead);

            if (!dst.Has(styleName))
            {
                DimStyleTableRecord dstr = new DimStyleTableRecord
                {
                    Name     = styleName,
                    Dimscale = 12
                };
                dst.UpgradeOpen();
                dst.Add(dstr);
                db.TransactionManager.AddNewlyCreatedDBObject(dstr, true);
                dst.DowngradeOpen();
            }
        }
Esempio n. 16
0
        public static void SetCurrentDimStyle(string DimStyleName)
        {
            // Establish connections to the document and it's database
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db  = doc.Database;

            // Establish a transaction
            using (Transaction tr = doc.TransactionManager.StartTransaction())
            {
                DimStyleTable dst   = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForRead);
                ObjectId      dimId = ObjectId.Null;

                string message = string.Empty;
                if (!dst.Has(DimStyleName))
                {
                    CreateModifyDimStyle(DimStyleName, out message);
                    dimId = dst[DimStyleName];
                }
                else
                {
                    dimId = dst[DimStyleName];
                }

                DimStyleTableRecord dstr = (DimStyleTableRecord)tr.GetObject(dimId, OpenMode.ForRead);

                /* NOTE:
                 * If this code is used, and the updated style is current,
                 * an override is created for that style.
                 * This is not what I wanted.
                 */
                //if (dstr.ObjectId != db.Dimstyle)
                //{
                //    db.Dimstyle = dstr.ObjectId;
                //    db.SetDimstyleData(dstr);
                //}

                /* Simply by running these two lines all the time, any overrides to updated dimstyles get
                 * cleared away as happens when you select the parent dimstyle in AutoCAD.
                 */
                db.Dimstyle = dstr.ObjectId;
                db.SetDimstyleData(dstr);

                tr.Commit();
            }
        }
Esempio n. 17
0
        /// <summary>
        /// 치수선 스타일 ID 받아오기
        /// </summary>
        /// <param name="StyleName"></param>
        /// <returns></returns>
        public static ObjectId GetDimStyleId(string StyleName)
        {
            var styleID = ObjectId.Null;

            #region T
            using (Transaction T = AC.DB.TransactionManager.StartTransaction())
            {
                DimStyleTable DST = T.GetObject(AC.DB.DimStyleTableId, OpenMode.ForRead) as DimStyleTable;

                if (DST.Has(StyleName))
                {
                    styleID = DST[StyleName];
                }
            }
            #endregion

            return(styleID);
        }
Esempio n. 18
0
        /// <summary>
        /// 创建一个新的标注样式
        /// </summary>
        /// <param name="db">数据库对象</param>
        /// <param name="styleName">标注样式名</param>
        /// <returns>返回新建的标注样式的Id</returns>
        public static ObjectId AddDimStyle(this Database db, string styleName)
        {
            //打开标注样式表
            DimStyleTable dst = (DimStyleTable)db.DimStyleTableId.GetObject(OpenMode.ForRead);

            if (!dst.Has(styleName))//如果不存在名为styleName的标注样式,则新建一个标注样式
            {
                //定义一个新的标注样式表记录
                DimStyleTableRecord dstr = new DimStyleTableRecord();
                dstr.Name = styleName; //设置标注样式名
                dst.UpgradeOpen();     //切换标注样式表的状态为写以添加新的标注样式
                dst.Add(dstr);         //将标注样式表记录的信息添加到标注样式表中
                //把标注式表记录添加到事务处理中
                db.TransactionManager.AddNewlyCreatedDBObject(dstr, true);
                dst.DowngradeOpen(); //为了安全,将标注样式表的状态切换为读
            }
            return(dst[styleName]);  //返回新添加的标注样式表记录的ObjectId
        }
Esempio n. 19
0
        public static void ImportBlocksFromDwg(this Database destDb, string sourceFileName)
        {
            //创建一个新的数据库对象,作为源数据库,以读入外部文件中的对象
            Database sourceDb = new Database(false, true);

            try
            {
                //把DWG文件读入到一个临时的数据库中
                sourceDb.ReadDwgFile(sourceFileName, System.IO.FileShare.Read, true, null);
                //创建一个变量用来存储块的ObjectId列表
                ObjectIdCollection blockIds = new ObjectIdCollection();
                //获取源数据库的事务处理管理器
                ZwSoft.ZwCAD.DatabaseServices.TransactionManager tm = sourceDb.TransactionManager;
                //在源数据库中开始事务处理
                using (Transaction myT = tm.StartTransaction())
                {
                    //打开源数据库中的块表
                    DimStyleTable bt = (DimStyleTable)tm.GetObject(sourceDb.DimStyleTableId, OpenMode.ForRead, false);
                    //遍历每个块
                    foreach (ObjectId btrId in bt)
                    {
                        DimStyleTableRecord btr = (DimStyleTableRecord)tm.GetObject(btrId, OpenMode.ForRead, false);
                        //只加入命名块和非布局块到复制列表中
                        //if (!btr.IsAnonymous && !btr.IsLayout)
                        {
                            blockIds.Add(btrId);
                        }
                        btr.Dispose();
                    }
                    bt.Dispose();
                }
                //定义一个IdMapping对象
                IdMapping mapping = new IdMapping();
                //从源数据库向目标数据库复制块表记录
                sourceDb.Wblock(destDb, blockIds, Point3d.Origin, DuplicateRecordCloning.Ignore);
                //操作完成,销毁源数据库
                sourceDb.Dispose();
            }
            catch (ZwSoft.ZwCAD.Runtime.Exception ex)
            {
                Application.ShowAlertDialog("复制错误: " + ex.Message);
            }
        }
Esempio n. 20
0
        public static DimStyleTable GetDimStyleTable()
        {
            Document document = Active.Document;
            Database database = document.Database;

            using (Transaction transaction = database.TransactionManager.StartTransaction())
            {
                try
                {
                    DimStyleTable dimStyleTable = transaction.GetObject <DimStyleTable>(database.DimStyleTableId, OpenMode.ForRead);
                    return(dimStyleTable);
                }
                catch (Exception ex)
                {
                    Active.WriteMessage(ex.Message);
                    return(null);
                }
            }
        }
Esempio n. 21
0
        getDimStyleTable()
        {
            DimStyleTable dst = null;
            Database      DB  = BaseObjs._db;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    dst = (DimStyleTable)DB.DimStyleTableId.GetObject(OpenMode.ForRead);
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(ex.Message + " Dim.cs: line: 123");
            }
            return(dst);
        }
        private List <DimStyleTableRecord> GetDimStyles(Database db)
        {
            List <DimStyleTableRecord> alldimStyles = new List <DimStyleTableRecord>();
            List <DimStyleTableRecord> dimStyles    = new List <DimStyleTableRecord>();

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                DimStyleTable tblStyle = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForRead);
                alldimStyles = tblStyle.Cast <ObjectId>().Select(n => (DimStyleTableRecord)tr.GetObject(n, OpenMode.ForRead)).ToList();
            }
            foreach (DimStyleTableRecord item in alldimStyles)
            {
                if (item.Name.Contains('|'))
                {
                    continue;
                }
                dimStyles.Add(item);
            }
            return(dimStyles);
        }
Esempio n. 23
0
        public static ObjectId AddDimStyle(this Database db, string styleName, double dimasz, double dimexe, int dimtad, double dimtxt)
        {
            DimStyleTable dst = (DimStyleTable)db.DimStyleTableId.GetObject(OpenMode.ForRead);

            if (!dst.Has(styleName))
            {
                DimStyleTableRecord dstr = new DimStyleTableRecord
                {
                    Name   = styleName,
                    Dimasz = dimasz,
                    Dimexe = dimexe,
                    Dimtad = dimtad,
                    Dimtxt = dimtxt
                };

                dst.UpgradeOpen();
                dst.Add(dstr);
                db.TransactionManager.AddNewlyCreatedDBObject(dstr, true);
                dst.DowngradeOpen();
            }
            return(dst[styleName]);
        }
Esempio n. 24
0
        public void NewDimStyle()
        {
            Database db = Application.DocumentManager.MdiActiveDocument.Database;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                DimStyleTable DimTabb = (DimStyleTable)trans.GetObject(db.DimStyleTableId, OpenMode.ForRead);

                ObjectId dimId = ObjectId.Null;

                if (!DimTabb.Has("Test"))
                {
                    DimTabb.UpgradeOpen();

                    DimStyleTableRecord newRecord = new DimStyleTableRecord();

                    newRecord.Name = "Test";

                    dimId = DimTabb.Add(newRecord);

                    trans.AddNewlyCreatedDBObject(newRecord, true);
                }

                else
                {
                    dimId = DimTabb["Test"];
                }

                DimStyleTableRecord DimTabbRecaord = (DimStyleTableRecord)trans.GetObject(dimId, OpenMode.ForRead);

                if (DimTabbRecaord.ObjectId != db.Dimstyle)
                {
                    db.Dimstyle = DimTabbRecaord.ObjectId;
                    db.SetDimstyleData(DimTabbRecaord);
                }
                trans.Commit();
            }
        }
Esempio n. 25
0
        public void CreatedimStyle()
        {
            Database db = HostApplicationServices.WorkingDatabase;
            Editor   ed = Application.DocumentManager.MdiActiveDocument.Editor;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                DimStyleTable dt      = (DimStyleTable)trans.GetObject(db.DimStyleTableId, OpenMode.ForWrite);
                String        dimName = "abc";
                ObjectId      dimId   = ISO25(dimName);
                if (dimId != ObjectId.Null)
                {
                    DimStyleTableRecord dtr = (DimStyleTableRecord)trans.GetObject(dimId, OpenMode.ForWrite);
                    // 修改箭头大小.
                    dtr.Dimasz = 3;
                }
                else
                {
                    ed.WriteMessage("\n标注样式 " + dimName + " 已存在!");
                }
                trans.Commit();
            }
        }
Esempio n. 26
0
        /// <summary>
        /// 绘制断面、量表
        /// </summary>
        /// <param name="db"></param>
        /// <param name="AnchorPoint"></param>
        public void PlotB(Database db, Point2d AnchorPoint)
        {
            int ScaleB = 50;

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                BlockTable       blockTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
                BlockTableRecord ms       = tr.GetObject(blockTbl[BlockTableRecord.ModelSpace],
                                                         OpenMode.ForWrite) as BlockTableRecord;
                DimStyleTable dst      = (DimStyleTable)tr.GetObject(db.DimStyleTableId, OpenMode.ForRead);
                string        blkname  = string.Format("T321-C{0}L{1}", Columns, Layers);
                ObjectId      blkRecId = blockTbl[blkname];
                using (BlockReference acBlkRef = new BlockReference(AnchorPoint.Convert3D(), blkRecId))
                {
                    ms.AppendEntity(acBlkRef);
                    tr.AddNewlyCreatedDBObject(acBlkRef, true);
                }
                tr.Commit();
            }

            // 图名
            TextPloter.PrintTitle(db, "标准横断面", AnchorPoint.Convert2D(0, 20 * ScaleB), ScaleB);
        }
Esempio n. 27
0
        public void AddDimStyleFromDWG()
        {
            Document mdiActiveDocument = Application.DocumentManager.MdiActiveDocument;
            Database database          = mdiActiveDocument.Database;

            try
            {
                using (Transaction transaction = database.TransactionManager.StartTransaction())
                {
                    DimStyleTable dimStyleTable = (DimStyleTable)transaction.GetObject(database.DimStyleTableId, 1);
                    if (!dimStyleTable.Has("DIM100"))
                    {
                        string   text      = Class33.Class31_0.Info.DirectoryPath + "\\support\\DimStyle.Dwg";
                        Database database2 = new Database(false, true);
                        database2.ReadDwgFile(text, FileShare.Read, true, "");
                        DimStyleTableRecord dimStyleTableRecord;
                        using (Transaction transaction2 = database2.TransactionManager.StartTransaction())
                        {
                            DimStyleTable dimStyleTable2 = (DimStyleTable)transaction2.GetObject(database2.DimStyleTableId, 0);
                            dimStyleTableRecord = (DimStyleTableRecord)transaction2.GetObject(dimStyleTable2["DIM100"], 0);
                            transaction2.Dispose();
                        }
                        mdiActiveDocument.Editor.WriteMessage("\n" + dimStyleTableRecord.Name);
                        DimStyleTableRecord dimStyleTableRecord2 = new DimStyleTableRecord();
                        dimStyleTableRecord2 = (DimStyleTableRecord)dimStyleTableRecord.Clone();
                        dimStyleTable.Add(dimStyleTableRecord2);
                        transaction.AddNewlyCreatedDBObject(dimStyleTableRecord2, true);
                        mdiActiveDocument.Editor.WriteMessage("\n标注样式:DIM100添加成功");
                    }
                    transaction.Commit();
                }
            }
            catch (Exception ex)
            {
                mdiActiveDocument.Editor.WriteMessage("\n标注样式加载出错: " + ex.Message);
            }
        }
Esempio n. 28
0
        public static ObjectId AddDimStyle(Database db, string DimName)//添加标注样式
        {
            DimStyleTable table = (DimStyleTable)db.DimStyleTableId.GetObject(OpenMode.ForRead);

            if (!table.Has(DimName))
            {
                DimStyleTableRecord record = new DimStyleTableRecord();
                record.Name   = DimName;
                record.Dimasz = 0.5;
                record.Dimtxt = 0.5;
                record.Dimtad = 1;
                record.Dimdec = 3;
                record.Dimtad = 1;
                //文字
                record.Dimtih          = false;
                record.Dimtoh          = false;
                record.Dimtxtdirection = false;
                table.UpgradeOpen();
                table.Add(record);
                db.TransactionManager.AddNewlyCreatedDBObject(record, true);
                table.DowngradeOpen();
            }
            return(table[DimName]);
        }
Esempio n. 29
0
        public static ObjectId CreateDimStyle(string _name, ObjectId _text, ObjectId _arrow)
        {
            Document mdiActiveDocument = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
            Database database          = mdiActiveDocument.Database;
            Editor   editor            = mdiActiveDocument.Editor;
            ObjectId result;

            using (mdiActiveDocument.LockDocument())
            {
                using (Transaction transaction = database.TransactionManager.StartTransaction())
                {
                    DimStyleTable dimStyleTable = transaction.GetObject(database.DimStyleTableId, OpenMode.ForWrite) as DimStyleTable;
                    if (!dimStyleTable.Has(_name))
                    {
                        DimStyleTableRecord dimStyleTableRecord = new DimStyleTableRecord();
                        dimStyleTableRecord.Name       = _name;
                        dimStyleTableRecord.Dimadec    = 2;
                        dimStyleTableRecord.Dimalt     = false;
                        dimStyleTableRecord.Dimaltd    = 0;
                        dimStyleTableRecord.Dimaltf    = 25.4;
                        dimStyleTableRecord.Dimaltrnd  = 0.0;
                        dimStyleTableRecord.Dimalttd   = 0;
                        dimStyleTableRecord.Dimalttz   = 0;
                        dimStyleTableRecord.Dimaltu    = 2;
                        dimStyleTableRecord.Dimaltz    = 0;
                        dimStyleTableRecord.Dimapost   = "";
                        dimStyleTableRecord.Dimarcsym  = 0;
                        dimStyleTableRecord.Dimatfit   = 3;
                        dimStyleTableRecord.Dimaunit   = 1;
                        dimStyleTableRecord.Dimazin    = 0;
                        dimStyleTableRecord.Dimblk     = _arrow;
                        dimStyleTableRecord.Dimblk1    = _arrow;
                        dimStyleTableRecord.Dimblk2    = _arrow;
                        dimStyleTableRecord.Dimcen     = 2.0;
                        dimStyleTableRecord.Dimclrd    = Color.FromColorIndex(ColorMethod.ByBlock, 8);
                        dimStyleTableRecord.Dimclre    = Color.FromColorIndex(ColorMethod.ByBlock, 8);
                        dimStyleTableRecord.Dimclrt    = Color.FromColorIndex(ColorMethod.ByBlock, 4);
                        dimStyleTableRecord.Dimdec     = 0;
                        dimStyleTableRecord.Dimdle     = 0.0;
                        dimStyleTableRecord.Dimdli     = 7.0;
                        dimStyleTableRecord.Dimdsep    = char.Parse("Null");
                        dimStyleTableRecord.Dimexe     = 0.1;
                        dimStyleTableRecord.Dimexo     = 0.1;
                        dimStyleTableRecord.Dimfrac    = 1;
                        dimStyleTableRecord.Dimgap     = 0.5;
                        dimStyleTableRecord.Dimldrblk  = _arrow;
                        dimStyleTableRecord.Dimlfac    = 1.0;
                        dimStyleTableRecord.Dimlim     = false;
                        dimStyleTableRecord.Dimltex1   = database.ByBlockLinetype;
                        dimStyleTableRecord.Dimltex2   = database.ByBlockLinetype;
                        dimStyleTableRecord.Dimltype   = database.ByBlockLinetype;
                        dimStyleTableRecord.Dimlunit   = 2;
                        dimStyleTableRecord.Dimlwd     = LineWeight.ByBlock;
                        dimStyleTableRecord.Dimlwe     = LineWeight.ByBlock;
                        dimStyleTableRecord.Dimpost    = "";
                        dimStyleTableRecord.Dimrnd     = 0.5;
                        dimStyleTableRecord.Dimsah     = true;
                        dimStyleTableRecord.Dimscale   = 0.2;
                        dimStyleTableRecord.Dimsd1     = false;
                        dimStyleTableRecord.Dimsd2     = false;
                        dimStyleTableRecord.Dimse1     = false;
                        dimStyleTableRecord.Dimse2     = false;
                        dimStyleTableRecord.Dimsoxd    = false;
                        dimStyleTableRecord.Dimtad     = 1;
                        dimStyleTableRecord.Dimtdec    = 1;
                        dimStyleTableRecord.Dimtfac    = 1.0;
                        dimStyleTableRecord.Dimtih     = false;
                        dimStyleTableRecord.Dimtix     = true;
                        dimStyleTableRecord.Dimtm      = 0.0;
                        dimStyleTableRecord.Dimtmove   = 2;
                        dimStyleTableRecord.Dimtofl    = true;
                        dimStyleTableRecord.Dimtoh     = false;
                        dimStyleTableRecord.Dimtol     = false;
                        dimStyleTableRecord.Dimtolj    = 0;
                        dimStyleTableRecord.Dimtp      = 0.0;
                        dimStyleTableRecord.Dimtsz     = 0.0;
                        dimStyleTableRecord.Dimtxsty   = _text;
                        dimStyleTableRecord.Dimtvp     = 0.0;
                        dimStyleTableRecord.Dimtxt     = 1.7;
                        dimStyleTableRecord.Dimtzin    = 8;
                        dimStyleTableRecord.Dimupt     = false;
                        dimStyleTableRecord.Dimzin     = 8;
                        dimStyleTableRecord.DimfxlenOn = true;
                        dimStyleTableRecord.Dimfxlen   = 40.0;
                        dimStyleTableRecord.Dimtxt     = 0.5;
                        dimStyleTableRecord.Dimasz     = 0.2;
                        result = dimStyleTable.Add(dimStyleTableRecord);
                        transaction.AddNewlyCreatedDBObject(dimStyleTableRecord, true);
                    }
                    else
                    {
                        result = dimStyleTable[_name];
                    }
                    transaction.Commit();
                }
            }
            return(result);
        }
Esempio n. 30
0
        public static void CADini()
        {
            // Get the current document and database
            Document acDoc   = Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            Editor   ed      = acDoc.Editor;

            // Start a transaction
            using (Transaction tr = acCurDb.TransactionManager.StartTransaction())
            {
                Dictionary <string, short> ldic = new Dictionary <string, short>()
                {
                    ["粗线"]  = 4,
                    ["细线"]  = 2,
                    ["标注"]  = 7,
                    ["中心线"] = 1,
                    ["虚线"]  = 3,
                    ["填充"]  = 8,
                    ["图框"]  = 8,
                    ["地质"]  = 8,
                };
                List <string> Lname = new List <string>()
                {
                    "CENTER", "DASHED"
                };
                LayerTable acLyrTbl;
                acLyrTbl = tr.GetObject(acCurDb.LayerTableId, OpenMode.ForRead) as LayerTable;
                LinetypeTable acLinTbl;
                acLinTbl = tr.GetObject(acCurDb.LinetypeTableId, OpenMode.ForRead) as LinetypeTable;
                foreach (string ltname in Lname)
                {
                    if (!acLinTbl.Has(ltname))
                    {
                        acCurDb.LoadLineTypeFile(ltname, "acad.lin");
                    }
                }
                LayerTableRecord acLyrTblRec = new LayerTableRecord();
                foreach (string key in ldic.Keys)
                {
                    short cid = ldic[key];
                    acLyrTblRec = new LayerTableRecord();
                    if (!acLyrTbl.Has(key))
                    {
                        acLyrTblRec.Color = Color.FromColorIndex(ColorMethod.ByAci, cid);
                        if (cid != 4)
                        {
                            acLyrTblRec.LineWeight = LineWeight.LineWeight013;
                        }
                        else
                        {
                            acLyrTblRec.LineWeight = LineWeight.LineWeight030;
                        }
                        if (cid == 1)
                        {
                            acLyrTblRec.LinetypeObjectId = acLinTbl["CENTER"];
                        }
                        if (cid == 3)
                        {
                            acLyrTblRec.LinetypeObjectId = acLinTbl["DASHED"];
                        }
                        if (key == "图框")
                        {
                            acLyrTblRec.IsPlottable = false;
                        }
                        if (key == "地质")
                        {
                            acLyrTblRec.IsPlottable = false;
                        }
                        acLyrTblRec.Name = key;
                        if (acLyrTbl.IsWriteEnabled == false)
                        {
                            acLyrTbl.UpgradeOpen();
                        }
                        acLyrTbl.Add(acLyrTblRec);
                        tr.AddNewlyCreatedDBObject(acLyrTblRec, true);
                    }
                    else
                    {
                        acLyrTblRec       = tr.GetObject(acLyrTbl[key], OpenMode.ForWrite) as LayerTableRecord;
                        acLyrTblRec.Color = Color.FromColorIndex(ColorMethod.ByAci, cid);
                        if (cid != 4)
                        {
                            acLyrTblRec.LineWeight = LineWeight.LineWeight013;
                        }
                        else
                        {
                            acLyrTblRec.LineWeight = LineWeight.LineWeight030;
                        }
                        if (cid == 1)
                        {
                            acLyrTblRec.LinetypeObjectId = acLinTbl["CENTER"];
                        }
                        if (cid == 3)
                        {
                            acLyrTblRec.LinetypeObjectId = acLinTbl["DASHED"];
                        }
                        if (key == "图框")
                        {
                            acLyrTblRec.IsPlottable = false;
                        }
                        if (key == "地质")
                        {
                            acLyrTblRec.IsPlottable = false;
                        }
                    }
                }
                if (!acLyrTbl.Has("sjx"))
                {
                    acLyrTblRec            = new LayerTableRecord();
                    acLyrTblRec.Color      = Color.FromColorIndex(ColorMethod.ByAci, 1);
                    acLyrTblRec.Name       = "sjx";
                    acLyrTblRec.LineWeight = LineWeight.LineWeight015;
                    if (acLyrTbl.IsWriteEnabled == false)
                    {
                        acLyrTbl.UpgradeOpen();
                    }
                    acLyrTbl.Add(acLyrTblRec);
                    tr.AddNewlyCreatedDBObject(acLyrTblRec, true);
                }
                if (!acLyrTbl.Has("dmx"))
                {
                    acLyrTblRec            = new LayerTableRecord();
                    acLyrTblRec.Color      = Color.FromColorIndex(ColorMethod.ByAci, 8);
                    acLyrTblRec.Name       = "dmx";
                    acLyrTblRec.LineWeight = LineWeight.LineWeight015;
                    if (acLyrTbl.IsWriteEnabled == false)
                    {
                        acLyrTbl.UpgradeOpen();
                    }
                    acLyrTbl.Add(acLyrTblRec);
                    tr.AddNewlyCreatedDBObject(acLyrTblRec, true);
                }


                //-------------------------------------------------------------------------------------------
                TextStyleTable st = tr.GetObject(acCurDb.TextStyleTableId, OpenMode.ForWrite) as TextStyleTable;
                if (!st.Has("EN"))
                {
                    TextStyleTableRecord str = new TextStyleTableRecord()
                    {
                        Name     = "En",
                        FileName = "times.ttf",
                        XScale   = 0.85,
                    };
                    st.Add(str);
                    tr.AddNewlyCreatedDBObject(str, true);
                }
                else
                {
                    TextStyleTableRecord str = tr.GetObject(st["En"], OpenMode.ForWrite) as TextStyleTableRecord;
                    str.FileName = "times.ttf";
                    str.XScale   = 0.85;
                }
                if (!st.Has("fsdb"))
                {
                    TextStyleTableRecord str2 = new TextStyleTableRecord()
                    {
                        Name            = "fsdb",
                        FileName        = "fsdb_e.shx",
                        BigFontFileName = "fsdb.shx",
                        XScale          = 0.75,
                    };
                    ObjectId textstyleid = st.Add(str2);
                    tr.AddNewlyCreatedDBObject(str2, true);
                }
                else
                {
                    TextStyleTableRecord str = tr.GetObject(st["fsdb"], OpenMode.ForWrite) as TextStyleTableRecord;
                    str.FileName        = "fsdb_e.shx";
                    str.BigFontFileName = "fsdb.shx";
                    str.XScale          = 0.75;
                }
                if (!st.Has("仿宋"))
                {
                    TextStyleTableRecord str2 = new TextStyleTableRecord()
                    {
                        Name     = "仿宋",
                        FileName = "仿宋_GB2312.ttf",
                        XScale   = 0.8,
                    };
                    ObjectId textstyleid = st.Add(str2);
                    tr.AddNewlyCreatedDBObject(str2, true);
                }
                else
                {
                    TextStyleTableRecord str = tr.GetObject(st["仿宋"], OpenMode.ForWrite) as TextStyleTableRecord;
                    str.FileName = "仿宋_GB2312.ttf";
                    str.XScale   = 0.8;
                }
                if (!st.Has("钢筋"))
                {
                    TextStyleTableRecord str2 = new TextStyleTableRecord()
                    {
                        Name     = "钢筋",
                        FileName = "FS-GB2312-Rebar.ttf",
                        XScale   = 0.8,
                    };
                    ObjectId textstyleid = st.Add(str2);
                    tr.AddNewlyCreatedDBObject(str2, true);
                }
                else
                {
                    TextStyleTableRecord str = tr.GetObject(st["钢筋"], OpenMode.ForWrite) as TextStyleTableRecord;
                    str.FileName = "FS-GB2312-Rebar.ttf";
                    str.XScale   = 0.8;
                }



                //-------------------------------------------------------------------------------------------
                DimStyleTable dst = (DimStyleTable)tr.GetObject(acCurDb.DimStyleTableId, OpenMode.ForWrite);
                foreach (int thescale in new int[] { 50, 75, 100, 125, 150, 200 })
                {
                    string scname            = "1-" + thescale.ToString();
                    DimStyleTableRecord dstr = new DimStyleTableRecord();
                    if (!dst.Has(scname))
                    {
                        dstr.Name       = "1-" + thescale.ToString();
                        dstr.Dimscale   = thescale;
                        dstr.Dimtxsty   = st["仿宋"];
                        dstr.Dimclrd    = Color.FromColorIndex(ColorMethod.ByAci, 6);
                        dstr.Dimclre    = Color.FromColorIndex(ColorMethod.ByAci, 6);
                        dstr.Dimdli     = 5.0;
                        dstr.Dimexe     = 1.0;
                        dstr.Dimexo     = 1.0;
                        dstr.DimfxlenOn = true;
                        dstr.Dimfxlen   = 4;
                        dstr.Dimtxt     = 2.5;
                        dstr.Dimasz     = 1.5;
                        dstr.Dimtix     = true;
                        dstr.Dimtmove   = 1;
                        dstr.Dimtad     = 1;
                        dstr.Dimgap     = 0.8;
                        dstr.Dimdec     = 0;
                        dstr.Dimtih     = false;
                        dstr.Dimtoh     = false;
                        dstr.Dimdsep    = '.';
                        //dstr.Dimlfac = 0.1;
                        dst.Add(dstr);
                        tr.AddNewlyCreatedDBObject(dstr, true);
                    }
                    else
                    {
                        dstr            = tr.GetObject(dst[scname], OpenMode.ForWrite) as DimStyleTableRecord;
                        dstr.Name       = "1-" + thescale.ToString();
                        dstr.Dimscale   = thescale;
                        dstr.Dimtxsty   = st["fsdb"];
                        dstr.Dimclrd    = Color.FromColorIndex(ColorMethod.ByAci, 6);
                        dstr.Dimclre    = Color.FromColorIndex(ColorMethod.ByAci, 6);
                        dstr.Dimdli     = 5.0;
                        dstr.Dimexe     = 1.0;
                        dstr.Dimexo     = 1.0;
                        dstr.DimfxlenOn = true;
                        dstr.Dimfxlen   = 4;
                        dstr.Dimtxt     = 2.5;
                        dstr.Dimasz     = 1.5;
                        dstr.Dimtix     = true;
                        dstr.Dimtmove   = 1;
                        dstr.Dimtad     = 1;
                        dstr.Dimgap     = 0.8;
                        dstr.Dimdec     = 0;
                        dstr.Dimtih     = false;
                        dstr.Dimtoh     = false;
                        dstr.Dimdsep    = '.';
                        dstr.Dimlfac    = 0.1;
                    }
                }
                //-------------------------------------------------------------------------------------------
                // 自定义块
                //-------------------------------------------------------------------------------------------
                BlockTable       bt  = (BlockTable)tr.GetObject(acCurDb.BlockTableId, OpenMode.ForRead);
                BlockTableRecord btr = new BlockTableRecord();

                //-------------------------------------------------------------------------------------------
                if (!bt.Has("BG"))
                {
                    btr.Name = "BG";
                    bt.UpgradeOpen();
                    bt.Add(btr);
                    tr.AddNewlyCreatedDBObject(btr, true);
                    Polyline Paa = new Polyline()
                    {
                        //Color = Color.FromColorIndex(ColorMethod.ByAci, 9),
                        //Layer = "标注",
                    };
                    Paa.AddVertexAt(0, new Point2d(0, 0), 0, 0, 200);
                    Paa.AddVertexAt(1, new Point2d(0, 200), 0, 0, 0);
                    btr.AppendEntity(Paa);
                    tr.AddNewlyCreatedDBObject(Paa, true);
                    AttributeDefinition curbg = new AttributeDefinition();
                    curbg.Position    = new Point3d(120, 200, 0);
                    curbg.Height      = 250;
                    curbg.WidthFactor = 0.75;
                    curbg.Tag         = "标高";
                    //curbg.Layer = "标注";
                    curbg.TextStyleId = st["fsdb"];
                    btr.AppendEntity(curbg);
                    tr.AddNewlyCreatedDBObject(curbg, true);
                }
                //-------------------------------------------------------------------------------------------
                if (!bt.Has("ZP"))
                {
                    BlockTableRecord btr2 = new BlockTableRecord();
                    btr2.Name = "ZP";
                    bt.UpgradeOpen();
                    bt.Add(btr2);
                    tr.AddNewlyCreatedDBObject(btr2, true);
                    Polyline Paa2 = new Polyline()
                    {
                        Color = Color.FromColorIndex(ColorMethod.ByAci, 9),
                    };
                    Paa2.AddVertexAt(0, new Point2d(0 - 350, 0), 0, 0, 80);
                    Paa2.AddVertexAt(1, new Point2d(200 - 350, 0), 0, 0, 0);
                    Paa2.AddVertexAt(2, new Point2d(900 - 350, 0), 0, 0, 0);
                    btr2.AppendEntity(Paa2);
                    tr.AddNewlyCreatedDBObject(Paa2, true);
                    AttributeDefinition curzp = new AttributeDefinition();
                    curzp.Position    = new Point3d(220 - 350, 0, 0);
                    curzp.Height      = 250;
                    curzp.WidthFactor = 0.75;
                    curzp.Tag         = "左坡";
                    curzp.TextStyleId = st["fsdb"];
                    btr2.AppendEntity(curzp);
                    tr.AddNewlyCreatedDBObject(curzp, true);
                }

                //-------------------------------------------------------------------------------------------
                if (!bt.Has("YP"))
                {
                    BlockTableRecord btr3 = new BlockTableRecord();
                    btr3.Name = "YP";
                    bt.UpgradeOpen();
                    bt.Add(btr3);
                    tr.AddNewlyCreatedDBObject(btr3, true);
                    Polyline Paa3 = new Polyline()
                    {
                        Color = Color.FromColorIndex(ColorMethod.ByAci, 9),
                    };
                    Paa3.AddVertexAt(0, new Point2d(0 + 350, 0), 0, 0, 80);
                    Paa3.AddVertexAt(1, new Point2d(-200 + 350, 0), 0, 0, 0);
                    Paa3.AddVertexAt(2, new Point2d(-900 + 350, 0), 0, 0, 0);
                    btr3.AppendEntity(Paa3);
                    tr.AddNewlyCreatedDBObject(Paa3, true);
                    AttributeDefinition curyp = new AttributeDefinition();
                    curyp.Position       = new Point3d(-220 + 350, 0, 0);
                    curyp.HorizontalMode = TextHorizontalMode.TextRight;
                    curyp.AlignmentPoint = curyp.Position;
                    curyp.Height         = 250;
                    curyp.WidthFactor    = 0.75;
                    curyp.Tag            = "右坡";
                    curyp.TextStyleId    = st["fsdb"];
                    btr3.AppendEntity(curyp);
                    tr.AddNewlyCreatedDBObject(curyp, true);
                }
                //-------------------------------------------------------------------------------------------

                //-------------------------------------------------------------------------------------------
                tr.Commit();
            }
        }