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";
Solved! Go to Solution.
Solved by norman.yuan. Go to Solution.
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.
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();
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.
Can't find what you're looking for? Ask the community or share your knowledge.