|
今天在做自定义引线的时候,参考了Kean的代码,稍微改造了一下,但是发现还是没有达到目的。我的代码如下:
- [CommandMethod("test")]
- public void test()
- {MLeader pMLeader = new MLeader();
- Point3d pos = new Point3d(200, 200, 0);
- int entityIndex=pMLeader.AddLeaderLine(pos);
- pMLeader.AddFirstVertex(0, pos);
- pMLeader.SetLastVertex(0, pos);
- pMLeader.DoglegLength = 0;
- MText pMtext = new MText();
- pMtext.Contents = "100";
- pMtext.Location = pos;
- pMtext.FlowDirection = FlowDirection.LeftToRight;
- pMLeader.MText = pMtext;
- pMLeader.LandingGap = 0;
- pMtext.Attachment = AttachmentPoint.TopRight;
- pMLeader.TextAlignmentType = TextAlignmentType.RightAlignment;
- pMLeader.TextAttachmentType = TextAttachmentType.AttachmentBottomLine;
- CADCore.ToModelSpace(pMLeader);}
复制代码
其中CADCore.ToModelSpace(pMLeader),调用了方法代码为:- /// <summary>
- /// 添加对象到模型空间
- /// </summary>
- /// <param name="ent">要添加的对象</param>
- /// <returns></returns>
- public static ObjectId ToModelSpace(Entity ent)
- {
- Database db = HostApplicationServices.WorkingDatabase;
- ObjectId entId;
- using (Transaction trans = db.TransactionManager.StartTransaction())
- {
- BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
- BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
- entId = btr.AppendEntity(ent);
- trans.AddNewlyCreatedDBObject(ent, true);
- trans.Commit();
- }
- return entId;
- }
复制代码
,运行后,利用测试命令 test,得到如图所示界面,属性界面为:我现在遇到两个问题:1.如何用程序将“连接位置-左”和“连接位置-右”这两个属性设置为其他值,例如”第一行顶部“。2.上述程序中,我已经将引线 AddFirstVertex和 SetLastVertex这个顶点值设置为相同值了,但是实际效果图中还是出现如下图红色方框直线,是否能够用程序将此两点变成相同两个点处(用手工进行拉伸操作可以实现),请求各位朋友帮忙解决其中之一问题,谢谢。。
|
|