Message 1 of 4
Not applicable
05-05-2017
05:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
can someone tell me what I am missing?
I am trying to create a new layout with the following code.
please assume I have entered a valid layout name and that that layout name is not already in use.
the issue is, it seems to work, the layout is created in the current AutoCAD doc however it does not seem to be valid, the layout cannot be activated and disappears if I activate any other layout.
clearly, i am doing something wrong, any ideas
[CommandMethod("JT_CREATELAYOUT")]
public void JT_CREATELAYOUT()
{
Editor ed = ACDAS.Application.DocumentManager.MdiActiveDocument.Editor;
Database db = HostApplicationServices.WorkingDatabase;
try
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
DBDictionary layouts = (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForWrite);
PromptStringOptions pso = new PromptStringOptions("\nEnter the layout name: ");
PromptResult PR = ed.GetString(pso);
string name = PR.StringResult;
ObjectId layoutId = LayoutManager.Current.CreateLayout(name);
tr.Commit();
}
}
catch (System.Exception ex)
{
ed.WriteMessage("\nError: " + ex.Message);
}
}
Solved! Go to Solution.