Hi, I am importing a .MIF File into AutoCAD though C# in AutoCAD Map 3D 2020. The column order in AutoCAD Object Data is not same as in MapInfo. Please find the below code and let me know if am missing anything and let me know for any other information.
MapInfo Column Order:
AutoCAD Column Order:
Sample C# Code:
using (DocumentLock docLock = doc.LockDocument())
{
foreach (FileInfo file in files)
{
string layerName = string.Empty;
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
lblProgress.Text = "Processing " + file.Name + " MapInfo File";
System.Windows.Forms.Application.DoEvents();
Autodesk.Gis.Map.ImportExport.Importer import = app.Application.Importer;
import.Init("MIF", selectedPath + "\\" + file.Name);
layerName = Path.GetFileNameWithoutExtension(selectedPath + "\\" + file.Name);
foreach (Autodesk.Gis.Map.ImportExport.InputLayer layer in import)
{
if (layerName.ToUpper().Equals("ADA", StringComparison.InvariantCultureIgnoreCase) || layerName.ToUpper().Equals("MPS", StringComparison.InvariantCultureIgnoreCase) || layerName.ToUpper().Equals("SAM", StringComparison.InvariantCultureIgnoreCase))
import.ImportPolygonsAsClosedPolylines = true;
layer.SetDataMapping(ImportDataMapping.NewObjectDataOnly, layerName);
}
import.Import(true);
tr.Commit();
}
}
}
Hi, I am importing a .MIF File into AutoCAD though C# in AutoCAD Map 3D 2020. The column order in AutoCAD Object Data is not same as in MapInfo. Please find the below code and let me know if am missing anything and let me know for any other information.
MapInfo Column Order:
AutoCAD Column Order:
Sample C# Code:
using (DocumentLock docLock = doc.LockDocument())
{
foreach (FileInfo file in files)
{
string layerName = string.Empty;
using (Transaction tr = doc.TransactionManager.StartTransaction())
{
lblProgress.Text = "Processing " + file.Name + " MapInfo File";
System.Windows.Forms.Application.DoEvents();
Autodesk.Gis.Map.ImportExport.Importer import = app.Application.Importer;
import.Init("MIF", selectedPath + "\\" + file.Name);
layerName = Path.GetFileNameWithoutExtension(selectedPath + "\\" + file.Name);
foreach (Autodesk.Gis.Map.ImportExport.InputLayer layer in import)
{
if (layerName.ToUpper().Equals("ADA", StringComparison.InvariantCultureIgnoreCase) || layerName.ToUpper().Equals("MPS", StringComparison.InvariantCultureIgnoreCase) || layerName.ToUpper().Equals("SAM", StringComparison.InvariantCultureIgnoreCase))
import.ImportPolygonsAsClosedPolylines = true;
layer.SetDataMapping(ImportDataMapping.NewObjectDataOnly, layerName);
}
import.Import(true);
tr.Commit();
}
}
}
Have you checked the Table.FieldDefinitions property in debugging to see the actual order of the fields? If they are the same as you saw displayed in Properties window, then, that is probably what the Import class does by design when importing MIF data.
Norman Yuan
Have you checked the Table.FieldDefinitions property in debugging to see the actual order of the fields? If they are the same as you saw displayed in Properties window, then, that is probably what the Import class does by design when importing MIF data.
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.