Class TLcdRevitModelDecoder

java.lang.Object
com.luciad.format.revit.TLcdRevitModelDecoder
All Implemented Interfaces:
ILcdModelDecoder, ILcdStatusSource

@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdRevitModelDecoder extends Object implements ILcdModelDecoder, ILcdStatusSource
This model decoder decodes Revit project files into an ILcdModel. For more information on how this model decoder handles Revit files, please consult The Revit data format article.

Input

File Required Entry point Description
*.rvt x x A supported Revit file.
or
File Required Entry point Description
*.rvt.index x x A text file containing relative path names to Revit files (one file per line) that belong to the same project and that have the same reference. Refer to the Combining multiple Revit files article for more details.

Supported transfer protocols

  • This decoder only supports data from a file system.

Model reference

Revit files can contain geo-referencing information itself, but that is not supported by this decoder. This section describes what strategies this decoder uses to find a suitable reference for the data.

  1. The model reference is obtained from an ILcdModelReferenceDecoder. The default reference decoder set on this model decoder is based on all model reference decoders annotated with the LcdService annotation. For example, you use a .prj file with WKT information, or a .epgs file with an EPSG code next to the input data.
  2. Alternatively, you can use a .llh file next to the input data with a single text line containing a longitude, latitude and height coordinate (defined in the default EPSG 4326 reference). This will then be used as a topocentric reference to position your model in the world.
  3. You can set a fallback model reference to be used when no reference information can be found next to the input data: see setDefaultModelReference(com.luciad.model.ILcdModelReference).
        decoder.setDefaultModelReference(fallbackModelReference);
    

If no geo-reference information can be found with any of these strategies, then the data will be loaded in its original, non-georeferenced coordinate system.
This is equivalent to setting a TLcdCartesianReference as fallback reference:

    decoder.setDefaultModelReference(new TLcdCartesianReference(TLcdDistanceUnit.METRE_UNIT,
                                                                TLcdDistanceUnit.METRE_UNIT,
                                                                TLcdDistanceUnit.METRE_UNIT));

Note: Data that is decoded in its original coordinate system, can not be visualized on a geographical map. The dataset must be geo-located with an external tool, after conversion has been done.

Model structure

This decoder can create 2 different kind of models:

  • The geometry model: this model contains the Revit geometry. The display name has the suffix "[GEOMETRY]"
  • The features model: this model contains the properties of the Revit family types (like doors, walls, etc.), together with their bounding box. This model is a TLcd2DBoundsIndexedModel, its display name has the suffix "[FEATURES]"

To specify the model type, you must use a TLcdBIMDataSource with the appropriate Type as input for the decodeSource(ILcdDataSource) and decodeModelMetadata(ILcdDataSource) methods. The geometry type is assumed for the decode(String) and decodeModelMetadata(String) methods.

The possibility to decode 2 different models is also reflected through the discoverDataSources(java.lang.String) method: it returns 2 ILcdDataSource instances, one for the geometry model and one for the features model, that can both be decoded using the decodeSource(ILcdDataSource) method.

Model descriptor

The type name of the model descriptor is "Revit".

Model elements

The objects in the model depend on the type of the model.

Sample code

Obtain the default model containing the geometry:
    ILcdModelDecoder decoder = new TLcdRevitModelDecoder();
    ILcdModel model = decoder.decode(sourceName);
Obtain the geometry model by using a TLcdBIMDataSource:
    ILcdModelDecoder decoder = new TLcdRevitModelDecoder();
    ILcdModel model = decoder.decodeSource(new TLcdBIMDataSource(sourceName, TLcdBIMDataSource.Type.GEOMETRY));
Obtain the features model by using a TLcdBIMDataSource:
    TLcdRevitModelDecoder decoder = new TLcdRevitModelDecoder();
    ILcdModel model = decoder.decodeSource(new TLcdBIMDataSource(sourceName, TLcdBIMDataSource.Type.FEATURES));

Thread safety

  • The decoding of models is thread-safe.
  • The decoded models are thread-safe for read access.

Supported versions and specifications

This decoder supports Revit versions from 2011 up to 2025.

Known limitations

  • Only Revit project files (.rvt) are supported. Revit template files (.rte) are not supported.
  • The color of the elements in the geometry model is based on the Graphics | Shading color property of the objects material in Revit. Additional patterns or textures defined on the material are ignored.

Notes

  • If not available, the decoder will try to create a binzx file next to the Revit file. This file contains a Binz dataset and additional metadata. It is used to improve the decoding time for future decode requests of the Revit file. If such a binzx file cannot be written (for instance because the directory of the Revit file is read-only), it is generated in a temp directory and deleted again when the model is returned.
  • Decoding large Revit files can take a considerable amount of time.
Since:
2024.0
  • Field Details

  • Constructor Details

    • TLcdRevitModelDecoder

      public TLcdRevitModelDecoder()
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • setDefaultModelReference

      public void setDefaultModelReference(ILcdModelReference aModelReference)
    • getDefaultModelReference

      public ILcdModelReference getDefaultModelReference()
    • getModelReferenceDecoder

      public ILcdModelReferenceDecoder getModelReferenceDecoder()
    • setModelReferenceDecoder

      public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
    • discoverDataSources

      public List<? extends ILcdDataSource> discoverDataSources(String aPath) throws IOException
      Description copied from interface: ILcdModelDecoder

      Retrieves a set of model-specific ILcdDataSource instances.

      By default, this method:

      Concrete model decoders might choose to return a set of ILcdDataSource, for instance, if the path references a collection of data sources.

      An example where this is useful is for container formats, such as NetCDF. A NetCDF file can contain multiple measurement layers. This ILcdModelDecoder.discoverDataSources(String) method allows you to distinguish between them using ILcdDataSources, where each measurement layer can be referenced to and decoded separately using ILcdModelDecoder.decodeSource(ILcdDataSource)

      Specified by:
      discoverDataSources in interface ILcdModelDecoder
      Parameters:
      aPath - A path to the data source to be decoded; typically a file path or a URL.
      Returns:
      If this model decoder returns true for ILcdModelDecoder.canDecodeSource(String), it will return a list containing at least a single ILcdDataSource.
      Throws:
      IOException - If this model decoder returns false for ILcdModelDecoder.canDecodeSource(String) or if any exceptions caused by IO problems or invalid data occur.
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Description copied from interface: ILcdModelDecoder
      Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return true for a source name while decode throws an exception for that same source name.

      For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be verified; typically a file name or a URL.
      Returns:
      true if this decoder can likely decode the data specified by the source name, false otherwise.
      See Also:
    • canDecodeSource

      public boolean canDecodeSource(ILcdDataSource aDataSource)
      Description copied from interface: ILcdModelDecoder

      Checks whether this model decoder can decode the data source(s), identified by the passed ILcdDataSource.

      For performance reasons, we strongly recommend that this will only be a simple test. For example: check the instance class of aDataSource, or check the file extension if it is a TLcdDataSource.

      The default implementation of this method will check if the given ILcdDataSource is a TLcdDataSource. If not, this method returns false. Otherwise, it delegates the source to the ILcdModelDecoder.canDecodeSource(String) method.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - the ILcdModelSource to be verified.
      Returns:
      true if this decoder can likely decode the data specified by aDataSource, false otherwise.
      See Also:
    • decodeSource

      public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException
      Description copied from interface: ILcdModelDecoder

      Creates a new model from the given data source.

      By default, this method:

      Specified by:
      decodeSource in interface ILcdModelDecoder
      Parameters:
      aDataSource - the ILcdDataSource to be decoded.
      Returns:
      a model containing the decoded data. While null is allowed, implementors are advised to throw an error instead.
      Throws:
      IOException - for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.
      
       public ILcdModel decodeSource(ILcdDataSource aDataSource) throws IOException {
         try {
           // Perform decoding ...
         } catch (RuntimeException e) {
           throw new IOException(e);
         }
       }
       
      See Also:
    • decodeModelMetadata

      public TLcdModelMetadata decodeModelMetadata(ILcdDataSource aDataSource) throws IOException
      Description copied from interface: ILcdModelDecoder
      Decodes metadata for the specified data source. By default, this decodes the model and returns the model metadata found on that model. Implementations can override this method to speed up the retrieval.
      Specified by:
      decodeModelMetadata in interface ILcdModelDecoder
      Parameters:
      aDataSource - the data source to be decoded.
      Returns:
      the model metadata for the data source, never null.
      Throws:
      IOException - if the metadata cannot be decoded for some reason.
      See Also:
    • decodeModelMetadata

      public TLcdModelMetadata decodeModelMetadata(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Decodes metadata for the specified data source. By default, this decodes the model and returns the model metadata found on that model. Implementations can override this method to speed up the retrieval.
      Specified by:
      decodeModelMetadata in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be decoded; typically a file name or a URL.
      Returns:
      the model metadata for the data source, never null.
      Throws:
      IOException - if the metadata cannot be decoded for some reason.
      See Also:
    • decode

      public ILcdModel decode(String aSourceName) throws IOException
      Description copied from interface: ILcdModelDecoder
      Creates a new model from the given data source.
      Specified by:
      decode in interface ILcdModelDecoder
      Parameters:
      aSourceName - the data source to be decoded; typically a file name or a URL.
      Returns:
      A model containing the decoded data. While null is allowed, implementors are advised to throw an error instead.
      Throws:
      IOException - for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.
      
         public ILcdModel decode( String aSourceName ) throws IOException {
            try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
               // Perform decoding ...
            } catch (RuntimeException e) {
               throw new IOException(e);
            }
         }
       
      See Also:
    • addStatusListener

      public void addStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource

      Registers the given listener so it will receive status events from this source.

      In case you need to register a listener which keeps a reference to an object with a shorter life-time than this status source, you can use a ALcdWeakStatusListener instance as status listener.

      Specified by:
      addStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to be notified when the status has changed.
    • removeStatusListener

      public void removeStatusListener(ILcdStatusListener aListener)
      Description copied from interface: ILcdStatusSource
      Removes the specified listener so it is no longer notified.
      Specified by:
      removeStatusListener in interface ILcdStatusSource
      Parameters:
      aListener - The listener to remove.