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: 

MapInfo columns are not in order in AutoCAD Object Data

1 REPLY 1
Reply
Message 1 of 2
subash.nalla
653 Views, 1 Reply

MapInfo columns are not in order in AutoCAD Object Data

subash.nalla
Enthusiast
Enthusiast

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:

subashnalla_0-1672316418290.png

 

AutoCAD Column Order:

 

subashnalla_1-1672316533814.png

 

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();
                                }
    }
}

 

 

0 Likes

MapInfo columns are not in order in AutoCAD Object Data

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:

subashnalla_0-1672316418290.png

 

AutoCAD Column Order:

 

subashnalla_1-1672316533814.png

 

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();
                                }
    }
}

 

 

1 REPLY 1
Message 2 of 2
norman.yuan
in reply to: subash.nalla

norman.yuan
Mentor
Mentor

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

Drive CAD With Code

EESignature

0 Likes

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

Drive CAD With Code

EESignature

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

Post to forums  

Autodesk Design & Make Report