RevitLinkType.Create
Description:
Creates a new Revit link type and loads the linked document.
Creates a new Revit link type and loads the linked document.
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.
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.
Overloads (2):
Create(Document,ModelPath,RevitLinkOptions)
public static LinkLoadResult Create(
Document document,
ModelPath path,
RevitLinkOptions options
)
-
documentThe document in which to create the Revit link.
-
pathThe path of the link to load. This may be a server path. This must be a full path.
-
optionsAn options class for loading Revit links.
Return Value
LinkLoadResult
An object containing the results of creating and loading
the Revit link type. It contains the ElementId of the new link.
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);
}
-
document is not a project document. -or- Server paths cannot be relative. -or- document already contains a linked model at path path. -or- The given path path is a cloud path which is not supported in this method. -or- The input path "path" does not represent a Revit model.
-
A non-optional argument was NULL
-
The model cannot be accessed due to lack of access privileges.
-
There is not a valid Revit file at path's location
-
Revit cannot customize worksets for this model.
-
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.
-
The document has no open transaction.