Active Contributor
Posts: 47
Registered: ‎03-16-2012
Message 1 of 2 (179 Views)

Reg: How to get the unreferenced image in dwg.

179 Views, 1 Replies
01-08-2013 07:06 AM

How to get the unreferenced image in dwg?using DB.ReadDWGFile Method .Do any one have sample ?? :smileyindifferent:

With Regards,
*Expert Elite*
Posts: 2,077
Registered: ‎04-29-2006
Message 2 of 2 (154 Views)

Re : Reg: How to get the unreferenced image in dwg.

01-08-2013 09:54 AM in reply to: varadan01



You can get the Raster definitions from the ACAD_IMAGE_DICT dictionary and use the Database.Purge() method to get the unreferenced ones.


Here's a little sample:


        public void Test()
            Document doc = AcAp.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            using (Database sideDb = new Database())
                sideDb.ReadDwgFile(@"C:\Temp\ImagesTest.dwg", System.IO.FileShare.ReadWrite, false, "");
                using (Transaction tr = sideDb.TransactionManager.StartTransaction())
                    DBDictionary NOD =
                        (DBDictionary)tr.GetObject(sideDb.NamedObjectsDictionaryId, OpenMode.ForRead);
                    if (NOD.Contains("ACAD_IMAGE_DICT"))
                        DBDictionary imgDict =
                            (DBDictionary)tr.GetObject((ObjectId)NOD["ACAD_IMAGE_DICT"], OpenMode.ForRead);
                        ObjectIdCollection ids = new ObjectIdCollection();
                        foreach (DBDictionaryEntry entry in imgDict)
                        foreach (DBDictionaryEntry entry in imgDict)
                            if (ids.Contains(entry.Value))
                                ed.WriteMessage("\n" + entry.Key);


Gilles Chanteau

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community