Create Method (Document, View, String, DWGImportOptions, LinkLoadResult)


Creates a new instance of DWG or DXF link type from a file path and loads the linked file.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 18.0.0.0 (18.0.0.420)
Since: 2018

Syntax

C#
public static ImportInstance Create(
	Document document,
	View DBView,
	string path,
	DWGImportOptions options,
	out LinkLoadResult linkLoadResult
)
Visual Basic
Public Shared Function Create ( _
	document As Document, _
	DBView As View, _
	path As String, _
	options As DWGImportOptions, _
	<OutAttribute> ByRef linkLoadResult As LinkLoadResult _
) As ImportInstance
Visual C++
public:
static ImportInstance^ Create(
	Document^ document, 
	View^ DBView, 
	String^ path, 
	DWGImportOptions^ options, 
	[OutAttribute] LinkLoadResult^% linkLoadResult
)

Parameters

document
Type: Autodesk.Revit.DB Document
The document in which to create the DWG or DXF link.
DBView
Type: Autodesk.Revit.DB View
The view into which the DWG or DXF link will be created.
path
Type: System String
The full path of the DWG or DXF file to link. The path must exist and must be a valid DWG or DXF file.
options
Type: Autodesk.Revit.DB DWGImportOptions
Various import options applicable to the DWG format. If a null reference ( Nothing in Visual Basic) , all options will be set to their respective default values.
linkLoadResult
Type: Autodesk.Revit.DB LinkLoadResult %
An object containing the results of creating and loading the DWG or DXF link. It contains the ElementId of the new created DWG or DXF link type.

Return Value

The new instance of DWG or DXF link type.

Remarks

This function creates a new DWG or DXF link type as well as a new instance of this link type. The new instance of DWG or DXF link type is returned by this function and the element id of the new DWG or DXF link type is contained in the LinkLoadResult.

If the given full path of the DWG or DXF file to link is already used by an existing DWG or DXF link type, a new instance of this existing DWG or DXF link type will be created and returned. The element id of the existing DWG or DXF link type is contained in the LinkLoadResult.

This function regenerates the input document.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException document has is in an edit mode or is in family mode. -or- Import is temporarily disabled. -or- The view is not printable. -or- NullOrEmpty -or- 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- One or more strings describing layer selection is invalid or empty. -or- The array of line weights is not valid; either it contains less than expected 255 values, or one or more values are out of range 1 to 16 -or- The scale is not valid as a CustomScale for use during import.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL
Autodesk.Revit.Exceptions FileArgumentNotFoundException The given path does not exist.
Autodesk.Revit.Exceptions InvalidOperationException Place by shared, and the host model and the link do not share the same coordinate system. Or place by shared, and the shared coordinates of the host model do not match the GIS coordinate system of the link.
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