.NET AutoCAD二次开发之路(四、文字篇) |
您所在的位置:网站首页 › cad编辑文字死机解决方法有哪些 › .NET AutoCAD二次开发之路(四、文字篇) |
using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.Runtime; namespace Texts { public class Texts { [CommandMethod("AddText")] public void AddText() { Database db=HostApplicationServices.WorkingDatabase; using (Transaction trans=db.TransactionManager.StartTransaction()) { // 以只读方式打开块表 BlockTable acBlkTbl; acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable; // 以写方式打开模型空间块表记录 BlockTableRecord acBlkTblRec; acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord; DBText firsttext=new DBText(); // 创建第一个单行文字 firsttext.Position = new Point3d();//文字位置为原点 firsttext.Height = 5;//文字高度 //设置文字内容 firsttext.TextString = “This is firsttext!”; //设置文字的水平对齐方式为居中 firsttext.HorizontalMode = TextHorizontalMode.TextCenter; //设置文字的垂直对齐方式为居中 firsttext.VerticalMode = TextVerticalMode.TextVerticalMid; //设置文字的对齐点 firsttext.AlignmentPoint = firsttext.Position; acBlkTblRec.AppendEntity(firsttext); acTrans.AddNewlyCreatedDBObject(firsttext, true); trans.Commit();//提交事务处理 } } } } |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |