Get all external files from DWG

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
jcs
Posts: 2
Joined: 28 Sep 2023, 13:57

Get all external files from DWG

Post by jcs » 28 Sep 2023, 17:42

In c#, using "CADImport .NET" we can get all xrefs from a dwg file.

Code: Select all

CADEntityCollection xrefs = vCADFile.Converter.XRefs;
foreach (CADXRef rf in xrefs)
{
    System.Diagnostics.Debug.WriteLine(" ***" + rf.Path);
}
But, how I get all other external files included in a DWG? All images, pdfs, etc?

Thanks in advance.

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: Get all external files from DWG

Post by support » 29 Sep 2023, 15:02

jcs wrote:
28 Sep 2023, 17:42
In c#, using "CADImport .NET" we can get all xrefs from a dwg file.

Code: Select all

CADEntityCollection xrefs = vCADFile.Converter.XRefs;
foreach (CADXRef rf in xrefs)
{
    System.Diagnostics.Debug.WriteLine(" ***" + rf.Path);
}
But, how I get all other external files included in a DWG? All images, pdfs, etc?

Thanks in advance.
Hello,
I'm afraid I don't quite follow what external files in a DWG you mean. External references represent objects that exist outside a model file, but they are not files themselves. You can read more on XRefs in CAD .NET at
https://cadsofttools.ru/help/cadnet/ind ... ers--.html
If you want to get entities that are inside the XREF, you could do it using the CADEntity.Entities property.

Best regards,
Catherine
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

jcs
Posts: 2
Joined: 28 Sep 2023, 13:57

Re: Get all external files from DWG

Post by jcs » 29 Sep 2023, 16:53

Hello,

I found the solution. With this code:

Code: Select all

foreach (CADImageDef imdef in  vCADFile.Converter.ImageDefs)
{
    Debug.WriteLine(" *** IMAGE NAME: " + imdef.FileName);
}
The project has images outside the dwg and can't work without them. With this code we can extract these files.
Last edited by jcs on 29 Sep 2023, 16:54, edited 1 time in total.

Post Reply