.net 添加注记(一)
public void DrawAnno()
{
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = acDoc.Editor;
Point3d jigPt = Point3d.Origin;
PromptStringOptions pStrOpts = new PromptStringOptions("\n输入文字: ");
pStrOpts.AllowSpaces = true;
PromptResult pStrRes = acDoc.Editor.GetString(pStrOpts);
// 创建文字对象
DBText mText = new DBText();
// 文字对象的ID
ObjectId textId = new ObjectId();
mText.SetDatabaseDefaults();
mText.TextString = pStrRes.StringResult;
// 获取文字插入点
PromptPointOptions optPtKey = new PromptPointOptions("\n请输入点: ");
optPtKey.UseBasePoint = false;
PromptPointResult resKey = ed.GetPoint(optPtKey);
if(resKey.Status == PromptStatus.OK)
{
jigPt = resKey.Value;
// 获取文字旋转角度
PromptAngleOptions optAngle = new PromptAngleOptions("\n请指定文字旋转角度: ");
optAngle.UseBasePoint = true;
optAngle.BasePoint = jigPt;
PromptDoubleResult resAngle = ed.GetAngle(optAngle);
if (resAngle.Status == PromptStatus.OK)
{
mText.Justify = AttachmentPoint.MiddleCenter;
mText.AlignmentPoint = resKey.Value;
mText.Rotation = resAngle.Value;
Entity textEnt = (Entity)mText;
textId = myMethod.AppendEntity(textEnt);
}
}
}
http://bbs.mjtd.com/xwb/images/bgimg/icon_logo.png 该贴已经同步到 菜鸟Liu的微博 学习一下
多谢分享
页:
[1]