Database.CurrentSpaceId holds a objectID to current space. You can use this variable to identify whether the active space is model space or paper space. With use of “LayoutManager”, you can identify the current layout.
[CommandMethod("ActiveSpace")]
public void ActiveSpace()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
Database db = doc.Database;
ObjectId SpaceId = db.CurrentSpaceId;
//check if this is model psace.
ObjectId ModelSpaceId =
SymbolUtilityServices.GetBlockModelSpaceId(db);
if (ModelSpaceId == SpaceId)
{
ed.WriteMessage("Model space is active\n");
}
else
{
ed.WriteMessage("Paper space is active\n");
}
//use layer manager to get the current layout
LayoutManager layoutMgr = LayoutManager.Current;
ed.WriteMessage(layoutMgr.CurrentLayout +
" is current layout\n");
}