Import Method (String, DWGImportOptions, View, ElementId)


Imports a DWG or DXF file to the document.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 22.0.0.0 (22.1.0.0)

Syntax

C#
public bool Import(
	string file,
	DWGImportOptions options,
	View pDBView,
	out ElementId elementId
)
Visual Basic
Public Function Import ( _
	file As String, _
	options As DWGImportOptions, _
	pDBView As View, _
	<OutAttribute> ByRef elementId As ElementId _
) As Boolean
Visual C++
public:
bool Import(
	String^ file, 
	DWGImportOptions^ options, 
	View^ pDBView, 
	[OutAttribute] ElementId^% elementId
)

Parameters

file
Type: System String
Full path of the file to import. File must exist and must be a valid DWG or DXF file.
options
Type: Autodesk.Revit.DB DWGImportOptions
Various options applicable to the DWG or DXF format. If a null reference ( Nothing in Visual Basic) , all options will be set to their respective default values.
pDBView
Type: Autodesk.Revit.DB View
View used to aid placement of the imported file. If the options specify ThisViewOnly, this argument is required and the imported file will only be visible in the specified view. If the options specify center-to-center placement, this argument is required and the imported file will be placed in the center of the specified view. Otherwise, this view is used to obtain a base level to associate with the imported file. If not specified, an existing view will be chosen instead and may open a view or associate the imported file to an arbitrary level.
elementId
Type: Autodesk.Revit.DB ElementId %
The id of imported instance after a successful import.

Return Value

True if successful, otherwise False.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException Not a valid file for DWG import (.dwg and .dxf files are valid). -or- ThisViewOnly cannot be true when importing a DWG|DGN drawing into a 3D view. -or- The provided view is not valid for the options provided. -or- One or more strings describing layer selection is invalid or empty. -or- The line weights are not valid; either it contains an invalid number of line weights, or a line weight outside the valid range. -or- The scale is not valid as a CustomScale for use during import. -or- NullOrEmpty -or- The view is not printable.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was null
Autodesk.Revit.Exceptions FileArgumentNotFoundException The given file does not exist.
Autodesk.Revit.Exceptions InvalidOperationException Import is temporarily disabled.
Autodesk.Revit.Exceptions ModificationForbiddenException The document is in failure mode: an operation has failed, and Revit requires the user to either cancel the operation or fix the problem (usually by deleting certain elements). -or- The document is being loaded, or is in the midst of another sensitive process.
Autodesk.Revit.Exceptions ModificationOutsideTransactionException The document has no open transaction.
Autodesk.Revit.Exceptions OptionalFunctionalityNotAvailableException The DWG Import/Link module is not available in the installed Revit.

See Also