.NET

Reply
Active Contributor
murali.pandey
Posts: 31
Registered: ‎12-18-2008
Message 1 of 2 (428 Views)

coordinate system extraction

428 Views, 1 Replies
04-26-2012 10:11 PM

Hi

Anybody can tell me ,how can I extract coordinate system of a autocad Map dwg file by using C#. I have to use this information to set the coordinate system of other drawing.

 

Thanks

Murali

*Expert Elite*
norman.yuan
Posts: 1,063
Registered: ‎04-27-2009
Message 2 of 2 (400 Views)

Re: coordinate system extraction

04-27-2012 07:16 AM in reply to: murali.pandey

I assume by "coordinate system", you mean GIS coordinate system that assigned to a drawing in AutoCAD Map 3D/Civil 3D, right?

 

To do that you need to set reference to AutoCAD Map 3D GIS platform API assemblies. Depending on the version of AutoCAD Map, the assemblies' name changes since it is officially available in AutoCAD Map 2009 (2008 had preview version).

 

Anyway, to find out the GIS coordinate system assigned to a drawing, you can do this:

 

Autodesk.Gis.Map.Platform.AcMapMap map=Autodesk.Gis.Map.Platform.AcMapMap.GetCurrentMap()

string wkt=map.GetMapSRS()

if (string.IsNullOrEmpty(wkt))

    ''No coordinate system is assigned

else

{

    OSGeo.MapGuid.MgCoordinateSystemFactory factory=new OSGeo.MapGuide.NgCoordinateSystemFactory();

    //Get assigned CS. code, such as "UTM83-12"

    string csCode=factory.ConvertWktToCoordinateSystemCode(wkt);

}

 

However, when I ran this code in my AutoCAD Map 2009, GetMapSRS() sometimes does not return the coordinate system wellknown text on already opened drawing, even the drawing really has a CS assigned and I had to reopen the drawing. I have not tried this on later AutoCAD Map version. I am not sure it is the API bug in the early API version (Acad Map 2009) or my code error somewhere. Anyway, hope this be a little help.

 

BTW, for Acad Map specific, you may want to post to Acad Map Developing forum, but I guess a lot of regular visitors to this group may also actually use ACAD vertical like Acad Map/Civil anyway.

 

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.