FeatureSource using ReadDwgFile

FeatureSource using ReadDwgFile

Anonymous
Not applicable
786 Views
1 Reply
Message 1 of 2

FeatureSource using ReadDwgFile

Anonymous
Not applicable

Our busines case is to get a list of all .SHP file references within a .DWG file and report on these, as we are looking at moving where the DWG files and .SHP files are located.

 

we are having some issues getting the information out if the DWG is open via Datadase.ReadDwgFile, if we open the DWG via the interface the below code works fine, interesting though if we open the DWG via the interface and then also run this command, then it works as well! , any suggestion on who to get the FeatureSource information without opening the DWG via the interface

 

[CommandMethod("getFeatureSource")]      

publicvoid xx()

        {

           string dbPath = @"C:\anydwgwithShapeFile.dwg";

           

Database db = newDatabase(false, true);

            db.ReadDwgFile(dbPath,

FileOpenMode.OpenForReadAndAllShare, true, "");

           

           

MgResourceService rs = AcMapServiceFactory.GetService(MgServiceType.ResourceService) asAcMapResourceService;

           

MgResourceIdentifier ri = newMgResourceIdentifier(@"Library://");

           

           

MgByteReader reader = rs.EnumerateResources(ri, -1, MgResourceType.LayerDefinition);

           

MgByteReader reader2 = rs.EnumerateResources(ri, -1, MgResourceType.FeatureSource);

           

           

MessageBox.Show(reader.ToString());

           

MessageBox.Show(reader2.ToString());

            db.Dispose();

        }

 

 

Cheers

Warrick

 

0 Likes
787 Views
1 Reply
Reply (1)
Message 2 of 2

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

I have never tried to access the FDO-objects without having the drawing loaded into the Editor. And as you don't get errors when you load the data into the editor it may be the source of problem (not to have loaded it as current drawing in the Editor).

 

Anyway, would it help to analyse the dictionaries within the DWG? If so look to the NOD ==> "Autodesk_MAP" ==> "FSD_Dictionary" (and all the other stuff within "Autodesk_MAP"), to just get the info what SHP's are referenced you may find this position a good base for searching.

 

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes