Getting linked file data w/out opening the RVT

Here’s how to get information about linked files (DWG, RVT, etc) without having to first open the file

public void GetRVTLinks()
{
    ModelPath mp = new FilePath(@"C:\Users\harry_000\Documents\testFile.rvt");
    TransmissionData td = TransmissionData.ReadTransmissionData(mp);
    string s = "ExternalFileReferenceType\tPathType\tFile Path" + Environment.NewLine;
    foreach (ElementId id in td.GetAllExternalFileReferenceIds())
    {
        ExternalFileReference extRef = td.GetLastSavedReferenceData(id);
        s += extRef.ExternalFileReferenceType.ToString() + "\t" +
             extRef.PathType.ToString() + "\t" + 
            ModelPathUtils.ConvertModelPathToUserVisiblePath(extRef.GetPath()) + Environment.NewLine;
    }
    
    string outputfile = Path.Combine(Path.GetTempPath(),"links.txt");
    using (StreamWriter sw = new StreamWriter(outputfile,false))
    {
        sw.Write(s);
    }
    
    Process.Start(outputfile);
}
Advertisements

3 thoughts on “Getting linked file data w/out opening the RVT

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s