Listing user defined page setup using .NET

By Virupaksha Aithal

User defined page setups are basically plotsetting objects that are stored in the dictionary "ACAD_PLOTSETTINGS". Below code shows the procedure to list the user defined page setups.

[CommandMethod("ListPageSetup")]
static public void ListPageSetup()
{
    Document doc = Application.DocumentManager.MdiActiveDocument;
    Database db = doc.Database;
    Editor ed = doc.Editor;
 
    using (Transaction Tx = 
                db.TransactionManager.StartTransaction())
    {
        DBDictionary NOD = 
                        Tx.GetObject(db.NamedObjectsDictionaryId, 
                               OpenMode.ForRead) as DBDictionary;
 
 
        DBDictionary plotSettingsDic = 
                    Tx.GetObject(db.PlotSettingsDictionaryId, 
                               OpenMode.ForRead) as DBDictionary;
 
        foreach (DictionaryEntry dicoEntry in plotSettingsDic)
        {
            PlotSettings plotSettings = 
                        Tx.GetObject((ObjectId)(dicoEntry.Value), 
                                OpenMode.ForRead) as PlotSettings;
            ed.WriteMessage("n - Page Setup: " 
                    + dicoEntry.Key.ToString() + " PlotConfig: ");
        }
 
        Tx.Commit();
    }
}

Comments

2 responses to “Listing user defined page setup using .NET”

  1. How can I list only the Model Space plot setups? The code in the post lists the plot setups from the Model Space and from Layout Space.

  2. Keith Brown Avatar
    Keith Brown

    Not sure if the previous poster ever found an answer but once you open the PlotSettings is has a value called ModelType which is a boolean to determine if it is modelSpace or not.

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading