Creates a new Revit link type and loads the linked document.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since: 2013
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Parameters
- document
- Type: Autodesk.Revit.DBDocument
The document in which to create the Revit link.
- path
- Type: Autodesk.Revit.DBModelPath
The path of the link to load. This may be a path of local disk, Revit Server or Cloud. This must be a full path.
- options
- Type: Autodesk.Revit.DBRevitLinkOptions
An options class for loading Revit links.
Return Value
An object containing the results of creating and loading the Revit link type. It contains the ElementId of the new link.Remarks
This function regenerates the input document. While the options argument allows specification of a path type, the input path argument must be a full path. Relative vs. absolute determines how Revit will store the path, but it needs a complete path to find the linked document initially.
Examples

public ElementId CreateRevitLink(Document doc, string pathName)
{
FilePath path = new FilePath(pathName);
RevitLinkOptions options = new RevitLinkOptions(false);
// Create new revit link storing absolute path to a file
LinkLoadResult result = RevitLinkType.Create(doc, path, options);
return (result.ElementId);
}

Public Function CreateRevitLink(doc As Document, pathName As String) As ElementId
Dim path As New FilePath(pathName)
Dim options As New RevitLinkOptions(False)
' Create new revit link storing absolute path to a file
Dim result As LinkLoadResult = RevitLinkType.Create(doc, path, options)
Return (result.ElementId)
End Function
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.ExceptionsArgumentException | document is not a project document. -or- Server paths cannot be relative. -or- document already contains a linked model at path path. -or- The path to be linked in is empty. -or- The input path "path" does not represent a Revit model. |
Autodesk.Revit.ExceptionsArgumentNullException | A non-optional argument was null |
Autodesk.Revit.ExceptionsFileAccessException | The model cannot be accessed due to lack of access privileges. |
Autodesk.Revit.ExceptionsFileNotFoundException | The path to be linked in doesn't exist. |
Autodesk.Revit.ExceptionsInvalidOperationException | The model is not allowed to access. -or- Revit cannot customize worksets for this model. -or- Revit cannot link a cloud model to non-cloud model. |
Autodesk.Revit.ExceptionsModificationForbiddenException | 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.ExceptionsModificationOutsideTransactionException | The document has no open transaction. |
Autodesk.Revit.ExceptionsRevitServerInternalException | Could be for any of the reasons that failed on service side. |
Autodesk.Revit.ExceptionsRevitServerUnauthenticatedUserException | User is not signed in with Autodesk id. |
Autodesk.Revit.ExceptionsRevitServerUnauthorizedException | User is not authorized to access the specified cloud model. |