2027 Method
Changes 0
M

RevitLinkType.Create

Description:
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.
Overloads (2):
Create(Document,ModelPath,RevitLinkOptions)
public static LinkLoadResult Create(
	Document document,
	ModelPath path,
	RevitLinkOptions options
)
  • document
    The document in which to create the Revit link.
  • path
    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
    An 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);
}