Importing DXF Files - MapBasic - 2023

MapInfo MapBasic Reference

Product type
Software
Portfolio
Locate
Product family
MapInfo
Product
MapInfo > MapBasic
Version
2023
Language
English
Product name
MapBasic
Title
MapInfo MapBasic Reference
First publish date
1985
Last updated
2023-09-12
Published on
2023-09-12T16:32:32.686312

Syntax

Import file_name 
	[ Type "DXF" ] 
	[ Into table_name ]
	[ Overwrite ]
	[ Warnings { On | Off } ] 
	[ Preserve 
		[ AttributeData ] [ Preserve ] [ Blocks As MultiPolygonRgns ] ] 
	[ CoordSys... ] 
	[ Autoflip ] 
	[ Transform
		( DXF_x1, DXF_y1 ) ( DXF_x2, DXF_y2 ) 
		( MI_x1, MI_y1 ) ( MI_x2, MI_y2 ) ] 
	[ Read 
		[ Integer As Decimal ] [ Read ] [ Float As Decimal ] ] 
	[ Store [ Handles ] [ Elevation ] [ VisibleOnly ] ]
	[ Layer DXF_layer_name
		[ Into table_name ] 
		[ Preserve 
			[ AttributeData ] [ Preserve ] [ Blocks As MultiPolygonRgns ] ] ] 
	[ Layer... ] 

file_name is a string that specifies the name of the file to import.

table_name specifies the name of the new table to create.

DXF_x1, DXF_y1, etc. are numbers that represent coordinates in the DXF file.

MI_x1, MI_y1, etc. are numbers that represent coordinates in the MapInfo table.

DXF_layer_name is a string representing the name of a layer in the DXF file.

Description

If you import a DXF file, the Import statement can include the following DXF-specific clauses.

Note: The order of the clauses is important; placing the clauses in the wrong order can cause compilation errors.

Warnings On or Warnings Off - Controls whether warning messages are displayed during the import operation. By default, warnings are off.

Preserve AttributeData - Include this clause if you want MapInfo Pro to preserve the attribute data from the DXF file.

Preserve Blocks As MultiPolygonRgns - Include this clause if you want MapInfo Pro to store all of the polygons from a DXF block record into one multiple-polygon region object. If you omit this clause, each DXF polygon becomes a separate MapInfo Pro region object.

CoordSys - Controls the projection and coordinate system of the table. For details, see CoordSys clause.

Autoflip - Include this option if you want the map's x-coordinates to be flipped around the center line of the map. This option is only allowed if you specify a non-Earth coordinate system.

Transform - Specifies a coordinate transformation. In the Transform clause, you specify the minimum and maximum x- and y-coordinates of the imported file, and you specify the minimum and maximum coordinates that you want to have in the MapInfo table.

Read Integer As Decimal - Include this clause if you want to store whole numbers from the DXF file in a decimal column in the new table. This clause is only allowed when you include the Preserve AttributeData clause.

Read Float As Decimal - Include this clause if you want to store floating-point numbers from the DXF file in a decimal column in the new table. This clause is only allowed when you include the Preserve AttributeData clause.

Store [Handles] [Elevation] [VisibleOnly] - If you include Handles, the MapInfo table stores handles (unique ID numbers of objects in the drawing) in a column called _DXFHandle. If you include Elevation, MapInfo Pro stores each object's center elevation in a column called _DXFElevation. (For lines, MapInfo Pro stores the elevation at the center of the line; for regions, MapInfo Pro stores the average of the object's elevation values.) If you include VisibleOnly, MapInfo Pro ignores invisible objects.

Layer clause - If you do not include any Layer clauses, all objects from the DXF file are imported into a single MapInfo table. If you include one or more Layer clauses, each DXF layer that you name becomes a separate MapInfo table.

If your DXF file contains multiple layers, and if your Import statement includes one or more Layer clauses, MapInfo Pro only imports the layers that you name. For example, suppose your DXF file contains four layers (layers 0, 1, 2, and 3). The following Import statement imports all four layers into a single MapInfo table:

Import "FLOORS.DXF" 
	Into "FLOORS.TAB" 
	Preserve AttributeData

The following statement imports layers 1 and 3, but does not import layers 0 or 2:

Import "FLOORS.DXF" 
	Layer "1" 
		Into "FLOOR_1.TAB" 
		Preserve AttributeData 
	Layer "3" 
		Into "FLOOR_3.TAB" 
		Preserve AttributeData