.NET

.NET

Reply
Valued Contributor
88 Posts
0 Kudos
Registered: ‎02-28-2012
Post 1 of 2
Accepted Solution

Getting attached file details in Drawing file

212 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
687 Posts
80 Kudos
Registered: ‎06-02-2009
Post 2 of 2

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
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!