TransmissionData Class


A class representing information on all external file references in a document.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Since: 2012

Syntax

C#
public class TransmissionData : IDisposable
Visual Basic
Public Class TransmissionData _
	Implements IDisposable
Visual C++
public ref class TransmissionData : IDisposable

Remarks

TransmissionData stores information on both the previous state and requested state of an external file reference. This means that it stores the load state and path of the reference from the most recent time this TransmissionData's document was opened. It also stores load state and path information for what Revit should do the next time the document is opened.

As such, TransmissionData can be used to perform operations on external file references without having to open the entire associated Revit document. The methods ReadTransmissionData and WriteTransmissionData can be used to obtain information about external references, or to change that information. For example, calling WriteTransmissionData with a TransmissionData object which has had all references set to LinkedFileStatus.Unloaded would cause no references to be loaded upon next opening the document.

TransmissionData cannot add or remove references to external files. If, on file open, Revit discovers information in the TransmissionData which does not correspond to an existing external file reference, the information will be ignored on file load.

The TransmissionData for a document does not contain information about references which come from external servers. TransmissionData only contains references to local files or Revit links on Revit Server. TransmissionData cannot be used to change a reference from a local file reference to an external server reference.

Note that TransmissionData objects must be set to "transmitted" for the requested reference data to be meaningful. Revit ignores the TransmissionData for non-transmitted files. Marking a file as transmitted has other effects - workshared files are opened as detached from the central model, and creation of new local files is prohibited, until the file is in its final location and the file has been marked as no longer transmitted.

Examples

Copy C#
void UnloadRevitLinks(ModelPath location)
///  This method will set all Revit links to be unloaded the next time the document at the given location is opened. 
///  The TransmissionData for a given document only contains top-level Revit links, not nested links.
///  However, nested links will be unloaded if their parent links are unloaded, so this function only needs to look at the document's immediate links. 
{
   // access transmission data in the given Revit file
   TransmissionData transData = TransmissionData.ReadTransmissionData(location);

   if (transData != null)
   {
      // collect all (immediate) external references in the model
      ICollection<ElementId> externalReferences = transData.GetAllExternalFileReferenceIds();

      // find every reference that is a link
      foreach (ElementId refId in externalReferences)
      {
         ExternalFileReference extRef = transData.GetLastSavedReferenceData(refId);

         if (extRef.ExternalFileReferenceType == ExternalFileReferenceType.RevitLink)
         {
            // we do not want to change neither the path nor the path-type
            // we only want the links to be unloaded (shouldLoad = false)
            transData.SetDesiredReferenceData(refId, extRef.GetPath(), extRef.PathType, false);
         }
      }

      // make sure the IsTransmitted property is set 
      transData.IsTransmitted = true;

      // modified transmission data must be saved back to the model
      TransmissionData.WriteTransmissionData(location, transData);
   }
   else
   {
      Autodesk.Revit.UI.TaskDialog.Show("Unload Links", "The document does not have any transmission data");
   }
}
Copy VB.NET
Private Sub UnloadRevitLinks(location As ModelPath)
    '  This method will set all Revit links to be unloaded the next time the document at the given location is opened. 
    '  The TransmissionData for a given document only contains top-level Revit links, not nested links.
    '  However, nested links will be unloaded if their parent links are unloaded, so this function only needs to look at the document's immediate links. 
    ' access transmission data in the given Revit file
    Dim transData As TransmissionData = TransmissionData.ReadTransmissionData(location)

    If transData IsNot Nothing Then
        ' collect all (immediate) external references in the model
        Dim externalReferences As ICollection(Of ElementId) = transData.GetAllExternalFileReferenceIds()

        ' find every reference that is a link
        For Each refId As ElementId In externalReferences
            Dim extRef As ExternalFileReference = transData.GetLastSavedReferenceData(refId)

            If extRef.ExternalFileReferenceType = ExternalFileReferenceType.RevitLink Then
                ' we do not want to change neither the path nor the path-type
                ' we only want the links to be unloaded (shouldLoad = false)
                transData.SetDesiredReferenceData(refId, extRef.GetPath(), extRef.PathType, False)
            End If
        Next

        ' make sure the IsTransmitted property is set 
        transData.IsTransmitted = True

        ' modified transmission data must be saved back to the model
        TransmissionData.WriteTransmissionData(location, transData)
    Else
        Autodesk.Revit.UI.TaskDialog.Show("Unload Links", "The document does not have any transmission data")
    End If
End Sub

Inheritance Hierarchy

System Object
Autodesk.Revit.DB TransmissionData

See Also