AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to Set a map coordinate system to an existing drawing

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
dan.popescu9NZJ8
1032 Views, 4 Replies

How to Set a map coordinate system to an existing drawing

I have 100 drawings having the wrong coordinate system.

There is a way to access the database of each drawing and set up the proper coordinate system

The code I found out is not for the side database is only for the current drawing:

Autodesk.Gis.Map.MapApplication mapApp = Autodesk.Gis.Map.HostMapApplicationServices.Application;
Autodesk.Gis.Map.Project.ProjectModel projModel = mapApp.ActiveProject;

projModel.Projection = "TN18F";

 

 

4 REPLIES 4
Message 2 of 5


I have 100 drawings having the wrong coordinate system.

No need to write any code.  The lower half of the built in ADESETCRDSYS command will let you assign a named coordinate system to multiple drawings.

Message 3 of 5

so my question is:  there is a way to change using .net programming the coordinate system by accessing the side database method? I want to create a program where i specify the drawings and i press a button to apply the desired cs-code to the existing drawings.

using (Database Database2 = new Database(false, true))
{
Database2.ReadDwgFile(file1, FileOpenMode.OpenForReadAndAllShare, true, "");
Database2.CloseInput(true);
HostApplicationServices.WorkingDatabase = Database2;

Autodesk.Gis.Map.Platform.AcMapMap Acmap = Autodesk.Gis.Map.Platform.AcMapMap.GetCurrentMap();
string string_current = Acmap.GetMapSRS();


Autodesk.Gis.Map.MapApplication mapApp = Autodesk.Gis.Map.HostMapApplicationServices.Application;
Autodesk.Gis.Map.Project.ProjectModel projModel = mapApp.ActiveProject;

using (Autodesk.AutoCAD.DatabaseServices.Transaction Trans2 = Database2.TransactionManager.StartTransaction())
{
projModel.Projection = "TN18F";

Trans2.Commit();
}
HostApplicationServices.WorkingDatabase = ThisDrawing.Database;
Database2.Dispose();

Message 4 of 5

Firstly, you only need to use Map ObjectARX ,NET API (ManagedMapApi), not need to deal with Geospatial (Platform) API here.

 

No, you cannot have access to Map .NET API from side database as the way you do with plain AutoCAD. However, Map .NET API provides a way to deal a bunch of drawings in similar fashion (e.g. access to them in memory without having to open in AutoCAD editor): DrawingSet. That is, with an empty drawing open and you obtain the ActiveProject of the MapApplication, then you create an Alias, if necessary, and then attach targeted drawings to the project. After this, you can loop through each attached drawing as if it is a side database, and an AttachedDrawing has a read/write property "Projection" for you to set to a named coordinate system.

 

Hope this helps.

Norman Yuan

Drive CAD With Code

EESignature

Message 5 of 5

thank you. I will try this.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


AutoCAD Beta