- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
// based on code from:
// http://adndevblog.typepad.com/au ... ity-belongs-to.html
[CommandMethod("EntityLayoutName","enl", CommandFlags.Modal)]
static public void GetEntityLayout()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
PromptEntityOptions peo = new PromptEntityOptions("\nSelect object >>");
PromptEntityResult res;
res = ed.GetEntity(peo);
if (res.Status != PromptStatus.OK)
return;
Entity ent = (Entity)tr.GetObject(res.ObjectId, OpenMode.ForRead);
if (ent == null)
return;
BlockTableRecord btr = tr.GetObject(ent.OwnerId, OpenMode.ForRead, true) as BlockTableRecord;
Layout lt = tr.GetObject(btr.LayoutId, OpenMode.ForRead, true) as Layout;
string layoutName = lt.LayoutName;
ed.WriteMessage("\nThe layout the selected entity belongs to is {0}", layoutName);
}
} |
|