Creates a new instance of a linked Revit project (RevitLinkType).
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Since: 2013
Syntax
C# |
---|
public static RevitLinkInstance Create( Document document, ElementId revitLinkTypeId ) |
Visual Basic |
---|
Public Shared Function Create ( _ document As Document, _ revitLinkTypeId As ElementId _ ) As RevitLinkInstance |
Visual C++ |
---|
public: static RevitLinkInstance^ Create( Document^ document, ElementId^ revitLinkTypeId ) |
Parameters
- document
- Type: Autodesk.Revit.DB..::..Document
The document in which the new instance should be created.
- revitLinkTypeId
- Type: Autodesk.Revit.DB..::..ElementId
The element id of the RevitLinkType.
Return Value
The newly-created RevitLinkInstance.
Remarks
Instances will be placed origin-to-origin.
This function cannot be used to create instances
of nested links.
Examples

public void CreateLinkInstances(Document doc, ElementId linkTypeId) { // Create revit link instance at origin RevitLinkInstance.Create(doc, linkTypeId); RevitLinkInstance instance2 = RevitLinkInstance.Create(doc, linkTypeId); Location location = instance2.Location; // Create a second instance of the link and offset it by 100 feet. location.Move(new XYZ(0, -100, 0)); }

Public Sub CreateLinkInstances(doc As Document, linkTypeId As ElementId) ' Create revit link instance at origin RevitLinkInstance.Create(doc, linkTypeId) Dim instance2 As RevitLinkInstance = RevitLinkInstance.Create(doc, linkTypeId) Dim location As Location = instance2.Location ' Create a second instance of the link and offset it by 100 feet. location.Move(New XYZ(0, -100, 0)) End Sub
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.Exceptions..::..ArgumentException | revitLinkTypeId isn't a RevitLinkType. -or- revitLinkTypeId is not a top-level link. -or- revitLinkTypeId is not a loaded RevitLinkType -or- document is not a project document. |
Autodesk.Revit.Exceptions..::..ArgumentNullException | A non-optional argument was NULL |
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. |