马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [CommandMethod("RenameLayout")]
- static public void renamelayoutName()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- //get the Layout name
- PromptStringOptions opts =
- new PromptStringOptions("Enter Layout name to change");
- opts.AllowSpaces = true;
- PromptResult layoutName = ed.GetString(opts);
- if (layoutName.Status != PromptStatus.OK)
- return;
- bool bUpdate = false;
- using (Transaction tr =
- db.TransactionManager.StartTransaction())
- {
- DBDictionary dLayouts = tr.GetObject(db.LayoutDictionaryId,
- OpenMode.ForRead) as DBDictionary;
- if (dLayouts.Contains(layoutName.StringResult))
- {
- bUpdate = true;
- }
- tr.Commit();
- }
- if (bUpdate)
- {
- LayoutManager acLayoutMgr = LayoutManager.Current;
- acLayoutMgr.RenameLayout(layoutName.StringResult,
- layoutName.StringResult + " - modified");
- doc.Editor.Regen();
- }
- else
- {
- ed.WriteMessage("No Layout with name "
- + layoutName.StringResult);
- }
- }
|