This seems to work if it helps
[CommandMethod("OpenAndChangeLayout", CommandFlags.Session)]
public void OpenAndChangeLayout()
{
DocumentCollection docMgr = Application.DocumentManager;
docMgr.DocumentCreated += new DocumentCollectionEventHandler(DocCreated);
docMgr.Open(@"C:\Test\Test.dwg", false);
}
public static void DocCreated(Object sender, DocumentCollectionEventArgs e)
{
Application.DocumentManager.DocumentCreated -= new DocumentCollectionEventHandler(DocCreated);
Document doc = e.Document;
Application.DocumentManager.MdiActiveDocument = doc;
Editor ed = doc.Editor;
LayoutManager.Current.CurrentLayout = "Model";
TypedValue[] tv = { new TypedValue((int)DxfCode.Start, "3DSOLID") };
SelectionFilter sf = new SelectionFilter(tv);
PromptSelectionResult psr = ed.SelectAll(sf);
SelectionSet ss = psr.Value;
foreach (SelectedObject so in ss)
{
ed.WriteMessage("\n " + so.ObjectId.ToString());
}
}