.NET

Reply
Valued Contributor
RamanSBV
Posts: 88
Registered: ‎02-28-2012
Message 1 of 2 (207 Views)
Accepted Solution

Getting attached file details in Drawing file

207 Views, 1 Replies
08-27-2012 03:52 AM

Hi,

 

 

Please guide me In retrieving  attached file details of drawing file

 

 

1. Attach DWG -- db.GetHostDwgXrefGraph(true);

2. Attach Image -- 

3. Attach DWF --   

4. Arttach DGN --

5. Attach PDF --

 

Regards,

Raman

You have to access the corresponding dictionary from the NOD and iterate through its content.

 

For example here is how to access the attached PDF dictionary and reload the pdfs:

 

 [CommandMethod("PdfNetReload")]
static public void PdfNetReload()
{
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;
string defDictKey = UnderlayDefinition.GetDictionaryKey(typeof(PdfDefinition));
if (!nod.Contains(defDictKey))
return;
DBDictionary pdfDict = Tx.GetObject(nod.GetAt(defDictKey), OpenMode.ForWrite) as DBDictionary;
foreach (DBDictionaryEntry entry in pdfDict)
{
PdfDefinition entryObj = Tx.GetObject(entry.Value, OpenMode.ForWrite) as PdfDefinition;
entryObj.Load(null);
ObjectIdCollection collection = entryObj.GetPersistentReactorIds();
foreach (ObjectId id in collection)
{
DBObject temObject = Tx.GetObject(id, OpenMode.ForRead);
if (temObject is PdfReference)
{
PdfReference pdfref = temObject as PdfReference;
pdfref.UpgradeOpen();
pdfref.RecordGraphicsModified(true);
}
}
}
Tx.Commit();
}
}

 

Regards,

Philippe.

ADN Support Specialist
philippe.leefsma
Posts: 646
Registered: ‎06-02-2009
Message 2 of 2 (183 Views)

Re: Getting attached file details in Drawing file

08-28-2012 01:41 AM in reply to: RamanSBV

You have to access the corresponding dictionary from the NOD and iterate through its content.

 

For example here is how to access the attached PDF dictionary and reload the pdfs:

 

 [CommandMethod("PdfNetReload")]
        static public void PdfNetReload()
        {
            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;

                string defDictKey = UnderlayDefinition.GetDictionaryKey(typeof(PdfDefinition));

                if (!nod.Contains(defDictKey))
                    return;

                DBDictionary pdfDict = Tx.GetObject(nod.GetAt(defDictKey), OpenMode.ForWrite) as DBDictionary;

                foreach (DBDictionaryEntry entry in pdfDict)
                {
                    PdfDefinition entryObj = Tx.GetObject(entry.Value, OpenMode.ForWrite) as PdfDefinition;
                    entryObj.Load(null);

                    ObjectIdCollection collection = entryObj.GetPersistentReactorIds();

                    foreach (ObjectId id in collection)
                    {
                        DBObject temObject = Tx.GetObject(id, OpenMode.ForRead);

                        if (temObject is PdfReference)
                        {
                            PdfReference pdfref = temObject as PdfReference;
                            pdfref.UpgradeOpen();
                            pdfref.RecordGraphicsModified(true);
                        }
                    }
                }

                Tx.Commit();
            }
        }

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.