Inserting a Revit Link file

By Augusto Goncalves

Starting on release 2013 it is possible create a RevitLinkType, which defines the link to a .rvt file, and then insert a new RevitLinkInstance on the project.

// Ask for the file name

System.Windows.Forms.OpenFileDialog

  openFileDlg = new OpenFileDialog();

if (openFileDlg.ShowDialog() != DialogResult.OK)

  return Result.Cancelled;

string rvtFileName = openFileDlg.FileName;

 

// Get the active document

UIDocument uiDoc = commandData.

  Application.ActiveUIDocument;

Document doc = uiDoc.Document;

 

// Create the Revit Link Type

FilePath mp = new FilePath(rvtFileName);

RevitLinkOptions lnkOp = new RevitLinkOptions(false);

RevitLinkLoadResult loadedLnkType =

  RevitLinkType.Create(doc, mp, lnkOp);

 

// Create the Revit Link Instance

RevitLinkInstance lnkInstance =

  RevitLinkInstance.Create(doc, loadedLnkType.ElementId);


Comments

3 responses to “Inserting a Revit Link file”

  1. Valdemar Avatar
    Valdemar

    How to indicate the type of Link Instance Placement: Auto – by centre, Auto – by beginning, Auto – by comon coordinates (all translated from Rusian, have no English version of Revit)? How to avoid emersion of window with information during linking process?

  2. Nicklas Østergaard Avatar
    Nicklas Østergaard

    How can I reload a link in case the link is already created?

  3. Nicklas,
    A call to RevitLinkType.Reload should do it..
    From the help file: Loads or reloads the Revit link from its currently-stored location. If the link is an external resource, Revit will contact the IExternalResourceServer to get the latest version of the link.
    Regards,
    Augusto Goncalves

Leave a Reply to Nicklas ØstergaardCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading