By Virupaksha Aithal
Each DWF underlay definitions are stored in the named object Dictionary under Dictionary name “ACAD_DWFDEFINITIONS”. Below code shows the procedure to go through the “ACAD_DWFDEFINITIONS” Dictionary and listing all the DWF definitions.
[CommandMethod("DWFUnderlayList")]
static public void DWFUnderlayList()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
using (Transaction tr =
db.TransactionManager.StartTransaction())
{
DBDictionary nod = (DBDictionary)tr.GetObject(
db.NamedObjectsDictionaryId, OpenMode.ForRead);
string defDictKey = UnderlayDefinition.GetDictionaryKey(
typeof(DwfDefinition));
if (nod.Contains(defDictKey))
{
DBDictionary dwfDict =
(DBDictionary)tr.GetObject(
nod.GetAt(defDictKey), OpenMode.ForRead);
foreach (DBDictionaryEntry entry in dwfDict)
{
DwfDefinition dwfDef = (DwfDefinition)tr.GetObject(
entry.Value, OpenMode.ForRead);
ed.WriteMessage(dwfDef.ActiveFileName + "n");
}
}
else
{
ed.WriteMessage("No DWF underlay in the drawing filen");
}
tr.Commit();
}
}

Leave a Reply