[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);
}
}