Link Method (String, DGNImportOptions, View, ElementId)


Links a DGN file into the project document.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Since: 2013

Syntax

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

Parameters

file
Type: System String
Full path of the file to link. File must exist and must be a valid DGN file.
options
Type: Autodesk.Revit.DB DGNImportOptions
Various import options applicable to the DGN 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
The view into which the file will be linked.
elementId
Type: Autodesk.Revit.DB ElementId %
The id of linked instance after a successful link.

Return Value

True if successful, otherwise False.

Remarks

Link isn't supported for family documents. Please use import instead.

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException Not a valid file for DGN import (.dgn 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 scale is not valid as a CustomScale for use during import. -or- NullOrEmpty -or- The view is not printable. -or- Empty DGN model view name characters -or- Visible layer only option must be set to false for DGN import
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. -or- This Document is not a project document.
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 DGN Import/Link module is not available in the installed Revit.

See Also

ArchiLabs

Stop fighting Revit automation.

Build repeatable BIM design and documentation workflows with scripts, data, and AI in one place, without wrestling brittle one-off automations.

Try ArchiLabs →