//
// KDUB
// Codehimbelonga kwb@theSwamp 20070112
// For AC2007: MSVS2005
#region usingdeclarations
using System;
//// Assembly acdbmgd .. ObjectDBX.NET Managed Wrapper
//// Assembly acmgd .. Autocad.NET Managed Wrapper
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Colors;
#endregion
#region usingAliases
// Forms : MessageBox,
using System.Windows.Forms;
// : DictionaryEntry,
using System.Collections;
//
using System.Collections.Generic;
// For StringCollection
using System.Collections.Specialized;
// For Plotting
using Autodesk.AutoCAD.PlottingServices;
//
using AcDb = Autodesk.AutoCAD.DatabaseServices;
using AcEd = Autodesk.AutoCAD.EditorInput;
using AcRx = Autodesk.AutoCAD.Runtime;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using DBTransMan = Autodesk.AutoCAD.DatabaseServices.TransactionManager;
#endregion
[assembly
: AcRx
.CommandClass(typeof(kdubTestStuff
.kdubTestClass))]
namespace kdubTestStuff
{
/// <summary>
/// Summary for kdubTestStuff
/// </summary>
public class kdubTestClass : AcRx.IExtensionApplication
{
/// <summary>
/// ---------------------------------------------------------------------------------------------
/// </summary>
[AcRx.CommandMethod("kbLAL")]
static public void
listAllLayouts()
{
AcDb.Database db = HostApplicationServices.WorkingDatabase;
AcEd.Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
try
{
using (AcDb.Transaction
tr = db.TransactionManager.StartTransaction())
{
AcDb.LayoutManager layoutMgr = AcDb.LayoutManager.Current;
ed.WriteMessage("LayoutManager.CurrentLayout = " + layoutMgr.CurrentLayout + "\n");
ed.WriteMessage("LayoutManager.Count = " + layoutMgr.LayoutCount.ToString() + "\n");
using (AcDb.DBDictionary
layoutDict = (AcDb.DBDictionary)tr.GetObject(db.LayoutDictionaryId, AcDb.OpenMode.ForRead))
{
foreach (DictionaryEntry layoutEntry in layoutDict)
{
using (AcDb.Layout
layoutObj = (AcDb.Layout)tr.GetObject((AcDb.ObjectId)(layoutEntry.Value), AcDb.OpenMode.ForRead))
{
ed.WriteMessage("Layout.LayoutName = " + layoutObj.LayoutName + "\n");
}
}
}
}
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
/// <summary>
/// ---------------------------------------------------------------------------------------------
/// </summary>
public void
Initialize()
{
//Let the user know what's happening while loading your stuff
AcEd.Editor ed = AcadApp.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage("\nLoading 'listAllLayouts' application ...");
ed.WriteMessage("\nConcept Code For AC2007, MSVS2005 :: kwb@theSwamp 20070112 ...");
ed.WriteMessage("\nUse kbLAL at command line to List all Current Layout Names\n");
}
public void
Terminate()
{
//Nothing to see here yet, move along !
}
}
}