.NET

.NET

Reply
Active Member
mattiash
Posts: 10
Registered: ‎02-08-2010
Message 1 of 12 (2,234 Views)

How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

2234 Views, 11 Replies
02-24-2010 10:59 PM
Hi,

I have some code (.Net addin application) that reads xrefs from a drawing. This code uses DataBase.GetHostDwgXrefGraph() and has worked fine until now.


However, now I've run into some drawings that references not only .dwg-files, but also .jpg-files.


In the XREF dialog in AutoCAD I can see that .jpg-files are referenced by the "parent" drawing, but GetHostDwgXrefGraph() doesn't seem to find the .jpg files.

I have attached some sample code to illustrate what I do (FindExternalReferences.cs). In that file, I have a CommandMethod "xrl" finds all references of the mdi document and writes to debug output in visual studio.


Also I added a zip-file containing a drawing "parent.dwg", and it referenes some other files that also are in the zip-file:
* Another .dwg - child.dwg
* sample-jpg.jpg
* OLE link - sample-word.docx
* PDF - sample-pdf.pdf
* WMF - sample-wmf.wmf

My top priority is to find referenced images (jpg, png, bmp), but I'd also be interested in how to find referenced OLE links, PDF and WMF.


Can I use GetHostDwgXrefGraph to accomplish this, or do I need to use some other method? Basically I'd like some code suggestion how I can find all referenced files from "parent.dwg" (not only the .dwg as my code works now).


Thanks in advance,
Mattias
*Tony Tanzillo
Message 2 of 12 (2,233 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

02-25-2010 11:21 AM in reply to: mattiash
Have a look at the Database's FileDependencyManager property.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6343866@discussion.autodesk.com...
Hi,

I have some code (.Net addin application) that reads xrefs from a drawing. This
code uses DataBase.GetHostDwgXrefGraph() and has worked fine until now.


However, now I've run into some drawings that references not only .dwg-files,
but also .jpg-files.


In the XREF dialog in AutoCAD I can see that .jpg-files are referenced by the
"parent" drawing, but GetHostDwgXrefGraph() doesn't seem to find the .jpg files.

I have attached some sample code to illustrate what I do
(FindExternalReferences.cs). In that file, I have a CommandMethod "xrl" finds
all references of the mdi document and writes to debug output in visual studio.


Also I added a zip-file containing a drawing "parent.dwg", and it referenes some
other files that also are in the zip-file:
* Another .dwg - child.dwg
* sample-jpg.jpg
* OLE link - sample-word.docx
* PDF - sample-pdf.pdf
* WMF - sample-wmf.wmf

My top priority is to find referenced images (jpg, png, bmp), but I'd also be
interested in how to find referenced OLE links, PDF and WMF.


Can I use GetHostDwgXrefGraph to accomplish this, or do I need to use some other
method? Basically I'd like some code suggestion how I can find all referenced
files from "parent.dwg" (not only the .dwg as my code works now).


Thanks in advance,
Mattias
Active Member
mattiash
Posts: 10
Registered: ‎02-08-2010
Message 3 of 12 (2,233 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

03-01-2010 01:32 AM in reply to: mattiash
Hi Tony, thanks for replying.

FileDependencyManager looks really interesting, however I found no documentation or samples on how to use it. By looking at FileDependencyManager in Visual Studio, it looks like it has methods for updating and erasing entries, but I found no way of enumerating all entries (???). Am I missing something obvious here? Do you have any suggestion on how to use the FileDependencyManager?

Thanks in advance,
Mattias
Active Contributor
btmsoftware
Posts: 38
Registered: ‎09-06-2007
Message 4 of 12 (2,233 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

05-05-2010 02:05 AM in reply to: mattiash
Mattias,

Have you found some examples somewhere (or do yo have some) and can you share them with me (us), I have the same requirements...

Thanx in advance
Contributor
vasantpadhiyar71
Posts: 23
Registered: ‎05-25-2012
Message 5 of 12 (1,412 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

05-25-2012 06:36 AM in reply to: mattiash

Hi,

 

Your code is good and it works fine..

 

But when I want to find only Direct Children then what to do?

 

 

Suppose I have a Drawing Structure like:
MasterRoot
    Root1
        MasterChild1
            Child
        MasterChild2
            Child
    Root2
        MasterChild1
            Child
        MasterChild2
            Child

When I use XrefGraph xg = mainDb.GetHostDwgXrefGraph(true); in Code then I get all the Files as a node including MasterRoot (say count=6).
If I want to get Only direct Children (here, Root1 and Root2)(means count=2 only), then wha i have to do?
Is it Possible?
Any help will be appreciated.

Thanks in Advance..

Thanks & Regards,
Vasant Padhiyar

Vasant PADHIYAR
Valued Contributor
rick_hgy
Posts: 77
Registered: ‎04-13-2009
Message 6 of 12 (1,372 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

06-12-2012 06:01 AM in reply to: mattiash

we meet same problem.

 

we can get the files attachment by Interop.TRANSMITTALLib.dll, but it's contain the pc3 and so on. 

 

Who has the perfect solution?

 

Thanks!

 

Rick

Contributor
vasantpadhiyar71
Posts: 23
Registered: ‎05-25-2012
Message 7 of 12 (1,357 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

06-12-2012 09:43 PM in reply to: rick_hgy

Hi,

 

Please Go through the following link for the Solution:

 

http://forums.autodesk.com/t5/NET/How-can-I-get-Direct-xref-of-a-Particular-Drawing-using-C-Code/m-p...

 

Hope it helps..

 

Thanks,

Vasant PADHIYAR
Valued Contributor
rick_hgy
Posts: 77
Registered: ‎04-13-2009
Message 8 of 12 (1,355 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

06-12-2012 09:53 PM in reply to: mattiash

Thanks, Vasant!

 

we can get all DWG reference file, but can't find the image(jpg/png/tiff)/PDF format file which attached my xref manager.

 

so your link's  soluton can get the image file name/path?

 

Thanks!

 

Rick

 

 

Valued Contributor
rick_hgy
Posts: 77
Registered: ‎04-13-2009
Message 9 of 12 (1,348 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

06-12-2012 10:45 PM in reply to: vasantpadhiyar71

Dear Vasant,

 

We tested the code in the new link(http://adndevblog.typepad.com/autocad/2012/06/finding-all-xrefs-in-the-current-database-using-cnet.h... it's can't find the image file's name/path.

 

Pls see the attachment of sample drawings with dwg/JPG xref files.

 

Thanks again!

 

Rick

 

 

 

 

Distinguished Contributor
Artvegas
Posts: 104
Registered: ‎04-21-2011
Message 10 of 12 (1,345 Views)

Re: How to programmatically find all references (xref dwg, jpg, pdf, OLE etc)?

06-12-2012 11:00 PM in reply to: rick_hgy
It is my understanding that the xref graphing part of the API only applies to xrefs. To handle pdfs and raster images you need to work more directly with the named objects dictionary, specifically the PdfDefinition and RasterImageDef classes. It should be noted that you can also access xrefs from the block table, because xrefs are essentially brought in as blocks. However xref graphing provides additional support for nesting (which doesn't apply with pdfs or images). Here are some samples posted by norman yuan for pdfs: http://forums.autodesk.com/t5/NET/Attach-PDF-or-RasterImage-Reload/m-p/3095024/. And for raster images: http://adndevblog.typepad.com/autocad/2012/05/how-to-insert-a-rasterimage-using-the-net-api.html I strongly recommend that you dig into the database structure to see what's going on under the hood. You can do this using the MgdDbg tool: http://adndevblog.typepad.com/autocad/2012/04/dwg-debugger-mgddbg-app-for-autocad-20122013.html Art
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.