Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.Exports package

Subpackages

Submodules

duHast.Revit.Exports.export module

This module contains a number of functions around exporting from Revit to varies file formats.

duHast.Revit.Exports.export.build_export_file_name_from_view(view_name, view_filter_rule, file_extension)

Function modifying the past in view name and returns a file name.

Parameters:
  • view_name (str) – The view name to be used as file name.

  • view_filter_rule (str) – A prefix which will be removed from the view name.

  • file_extension (str) – The file extension to be used. Format is ‘.something’

Returns:

A file name.

Return type:

str

duHast.Revit.Exports.export_data module

This module contains a number of functions around exporting from Revit to data objects.

duHast.Revit.Exports.export_data.get_element_properties(element)

Converts properties on a Revit element into data_property instances

Parameters:

element (Autodesk.Revit.DB.Element) – A Revit element

Returns:

A list of data_property instances

Return type:

[DataProperty]

duHast.Revit.Exports.export_data.get_type_properties(doc, element)

Returns a populated data type property instance.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The current Revit model document.

  • element (Autodesk.Revit.DB.Element) – A Revit element

Returns:

A data type properties instance

Return type:

[DataTypeProperties]

duHast.Revit.Exports.export_data.get_instance_properties(element)

Returns a populated data instance property instance.

Parameters:

element (Autodesk.Revit.DB.Element) – A Revit element

Returns:

A data instance properties instance

Return type:

[DataInstanceProperties]

duHast.Revit.Exports.export_data.get_level_data(doc, element, built_in_parameter_def)

Returns a populated data level instance.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The current Revit model document.

  • element (Autodesk.Revit.DB.Element) – A Revit element

  • built_in_parameter_def (Autodesk.Revit.DB.BuiltInParameter) – The build in parameter containing the offset from level

Returns:

A data level instance

Return type:

[DataLevel]

duHast.Revit.Exports.export_data.get_design_set_data(doc, element)

Returns a populated data design set option instance.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The current Revit model document.

  • element (Autodesk.Revit.DB.Element) – A Revit element

Returns:

A data design set instance

Return type:

[DataDesignSetOption]

duHast.Revit.Exports.export_data.get_phasing_data(doc, element)

Returns a data phase instance with names for created and demolished populated.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The current Revit model document.

  • element (Autodesk.Revit.DB.Element) – A Revit element

Returns:

A data phase instance

Return type:

[DataPhasing]

duHast.Revit.Exports.export_data.get_model_data(doc)

Returns a revit_model instance with the name populated. If detached and not saved yet it will be named “Detached Model”

Parameters:

doc (Autodesk.Revit.DB.Document) – The current Revit model document.

Returns:

A data revit model instance

Return type:

[DataRevitModel]

duHast.Revit.Exports.export_ifc module

This module contains a number of functions around exporting from Revit to nwc file format.

duHast.Revit.Exports.export_ifc.ifc_get_export_config_by_view(ifc_version, ifc_space_bounds=0)

Returns an IFC export configuration for the built in IFC exporter. :param ifc_version: The ifc version used for the export. :type ifc_version: Autodesk.Revit.DB.IFCVersion :param ifc_space_bounds: IFC space boundary setting, defaults to IFCSpaceBoundaries.noBoundaries :type ifc_space_bounds: SampleCodeBatchProcessor.RevitExport.IFCSpaceBoundaries, optional :return: an IFC export option :rtype: Autodesk.Revit.DB.IFCExportOptions

duHast.Revit.Exports.export_ifc.export_to_ifc(doc, ifc_export_option, directory_path, file_name)

Exports to IFC either the entire model or a view only using 3rd party exporter. What gets exported is defined in the ifc_export_option.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • ifc_export_option (Autodesk.Revit.DB IFCExportOptions) – The settings for the IFC export.

  • directory_path (str) – The directory path to where the export is being saved.

  • file_name (str) – The file name under which the export is being saved.

Returns:

Result class instance. - Export status returned in result.status. False if an exception occurred, otherwise True. - result.message will contain the fully qualified file path of the exported file. On exception: - result.status (bool) will be False. - result.message will contain the exception message.

Return type:

Result

duHast.Revit.Exports.export_ifc.export_3d_views_to_ifc_default(doc, view_filter, ifc_export_option, directory_path)

Exports 3D views matching a filter (view starts with) to IFC using the default built-in exporter.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • view_filter (str) – String the view name is to start with if it is to be exported. (Both view name and string are set to lowercase for comparison)

  • ifc_export_option (Autodesk.Revit.DB.IFCExportOptions) – The IFC export option.

  • directory_path (str) – The directory path to where the export is being saved.

Returns:

Result class instance. - result.status (bool): False if an exception occurred, otherwise True (export status). - result.message (str): Contains the fully qualified file path of the exported file.

On exception:
  • result.status (bool): False.

  • result.message (str): Contains the exception message.

Return type:

Result

duHast.Revit.Exports.export_ifc.setup_ifc_export_option(export_config, view_id=Autodesk.Revit.DB.ElementId.InvalidElementId, coord_option='0', convert_view_id_to_integer=True)

Function assigning a view Id to export ifc config if it is exporting by view. By model export will assign Autodesk.Revit.DB.ElementId.InvalidElementId instead. :param export_config: The ifc export configuration used. :type export_config: BIM.IFC.Export.UI.IFCExportConfiguration :param view_id: The id of the view to be exported, defaults to ElementId.InvalidElementId :type view_id: Autodesk.Revit.DB.ElementId, optional :param coord_option: Describes the coordinate options used for the export, defaults to IFCCoords.SharedCoordinates :type coord_option: SampleCodeBatchProcessor.RevitExport.IFCCoords, optional :return: An updated ifc export option instance. :rtype: Autodesk.Revit.DB.IFCExportOptions

duHast.Revit.Exports.export_ifc.export_3d_views_to_ifc(doc, view_filter, ifc_export_config, directory_path, ifc_coordinates_system='0', do_something_with_view_name=None)

Exports 3D views matching a filter (view starts with) to IFC using a 3rd party exporter.

By default, the file name of the export will be the same as the name of the view being exported.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • view_filter (str) – String the view name is to start with if it is to be exported. (Both view name and string are set to lowercase for comparison)

  • ifc_export_config (BIM.IFC.Export.UI.IFCExportConfiguration) – The IFC export configuration.

  • directory_path (str) – The directory path to where the export is being saved.

  • ifc_coordinates_system (SampleCodeBatchProcessor.RevitExport.IFCCoords, optional) – Describes the coordinate options used for the export, defaults to IFCCoords.SharedCoordinates.

  • do_something_with_view_name (function, optional) – A function that takes the view name as an argument and processes it. The modified view name is then used as the actual file name, defaults to None, which uses the view name unchanged as the export file name.

Returns:

Result class instance. - result.status (bool): False if an exception occurred, otherwise True (export status). - result.message (str): Contains the fully qualified file path of the exported file.

On exception:
  • result.status (bool): False.

  • result.message (str): Contains the exception message.

Return type:

Result

duHast.Revit.Exports.export_ifc.export_model_to_ifc(doc, ifc_export_config, directory_path, file_name, coord_option='0')

Function exporting the entire model to IFC using 3rd party exporter.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • ifc_export_config (BIM.IFC.Export.UI.IFCExportConfiguration) – The IFC export configuration.

  • directory_path (str) – The directory path to where the export is being saved.

  • file_name (str) – The file name under which the export is being saved.

  • coord_option (SampleCodeBatchProcessor.RevitExport.IFCCoords, optional) – Describes the coordinate options used for the export, defaults to IFCCoords.SharedCoordinates

Returns:

Result class instance. - Export status returned in result.status. False if an exception occurred, otherwise True. - result.message will contain the fully qualified file path of the exported file. On exception: - result.status (bool) will be False. - result.message will contain the exception message.

Return type:

Result

duHast.Revit.Exports.export_ifc.ifc_get_third_party_export_config_by_model(doc, ifc_version, ifc_settings=None)

Returns the 3rd party ifc config for export by model depending on revit version. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param ifc_version: The ifc version used for the export. :type ifc_version: Autodesk.Revit.DB.IFCVersion :raises ValueError: Raises an exception if the revit version in use is not supported by this script. :return: An ifc export config instance based on the Revit version. :rtype: BIM.IFC.Export.UI.IFCExportConfiguration

duHast.Revit.Exports.export_ifc.ifc_get_third_party_export_config_by_view(doc, ifc_version, ifc_settings=None)

Returns the 3rd party ifc config for export by view depending on revit version. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param ifc_version: The ifc version used for the export. :type ifc_version: Autodesk.Revit.DB.IFCVersion :raises ValueError: Raises an exception if the revit version in use is not supported by this script. :return: An ifc export config instance based on the Revit version. :rtype: BIM.IFC.Export.UI.IFCExportConfiguration

duHast.Revit.Exports.export_navis module

This module contains a number of functions around exporting from Revit to nwc file format.

duHast.Revit.Exports.export_navis.setup_nwc_custom_export_option(using_shared_coordinates, export_entire_model, export_links, split_model_by_level, export_parts, export_room_as_attributes, export_room_geometry, find_missing_materials, navis_parameters=Autodesk.Revit.DB.NavisworksParameters.All, convert_element_properties=False)

Return an NWC Export Options object as per values past oin. :param using_shared_coordinates: True shared coordinates will be used, otherwise project internal :type using_shared_coordinates: bool :param export_entire_model: True entire model will be exported, otherwise specific view. :type export_entire_model: bool :param export_links: True: Revit links will also be exported, otherwise not. :type export_links: bool :param split_model_by_level: True: model elements will be split by level, otherwise not. :type split_model_by_level: bool :param export_parts: True parts will be exported, otherwise not. :type export_parts: bool :param export_room_as_attributes: True room properties will be exported (can be slow!), otherwise not. :type export_room_as_attributes: bool :param export_room_geometry: True room geometry will be exported, otherwise not. :type export_room_geometry: bool :param find_missing_materials: True exporter will attempt to find missing materials, otherwise not :type find_missing_materials: bool

Parameters:
  • navis_parameters (Autodesk.Revit.DB.NavisworksParameters) – Options which specifies the parameter conversion of Navisworks Exporter. Default value is All.

  • convert_element_properties (bool) – True to convert element properties, false otherwise. Default value is false.

Returns:

A Navisworks .nwc export option.

Return type:

Autodesk.Revit.DB.NavisworksExportOptions

duHast.Revit.Exports.export_navis.setup_nwc_default_export_option_shared_by_view()

Return an NWC Export Options object with shared coordinates, export by View. :return: A Navisworks .nwc export option. :rtype: Autodesk.Revit.DB.NavisworksExportOptions

duHast.Revit.Exports.export_navis.export_to_nwc(doc, nwc_export_option, directory_path, file_name)

Exports either the entire model or a view to NWC (Navisworks Cache) format.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • nwc_export_option (Autodesk.Revit.DB.NavisworksExportOptions) – A Navisworks .nwc export option.

  • directory_path (str) – The directory path to where the export is being saved.

  • file_name (str) – The file name under which the export is being saved.

Returns:

Result class instance. - result.status (bool): False if an exception occurred, otherwise True (export status). - result.message (str): Contains the fully qualified file path of the exported file.

On exception:
  • result.status (bool): False.

  • result.message (str): Contains the exception message.

Return type:

Result

duHast.Revit.Exports.export_navis.export_model_to_nwc(doc, nwc_export_option, directory_path, file_name)

Exports the entire Revit model to NWC (Navisworks Cache) format.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • nwc_export_option (Autodesk.Revit.DB.NavisworksExportOptions) – A Navisworks .nwc export option.

  • directory_path (str) – The directory path where the export is being saved.

  • file_name (str) – The file name under which the export is being saved.

Returns:

Result class instance. - result.status (bool): False if an exception occurred, otherwise True (export status). - result.message (str): Contains the fully qualified file path of the exported file.

On exception:
  • result.status (bool): False.

  • result.message (str): Contains the exception message.

Return type:

Result

duHast.Revit.Exports.export_navis.export_3d_views_to_nwc(doc, view_filter, nwc_export_option, directory_path, do_something_with_view_name=None)

Exports 3D views matching a filter (view starts with) to NWC (Navisworks Cache) format.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – Current Revit model document.

  • view_filter (str) – String the view name is to start with if it is to be exported. (Both view name and string are set to lowercase for comparison)

  • nwc_export_option (Autodesk.Revit.DB.NavisworksExportOptions) – A Navisworks .nwc export option.

  • directory_path (str) – The directory path where the export is being saved.

  • do_something_with_view_name (function, optional) – A function that takes the view name as an argument and processes it. The modified view name is then used as the actual file name, defaults to None, which uses the view name unchanged as the export file name.

Returns:

Result class instance. - result.status (bool): False if an exception occurred, otherwise True (export status). - result.message (str): Contains the fully qualified file path of the exported file.

On exception:
  • result.status (bool): False.

  • result.message (str): Contains the exception message.

Return type:

Result

Module contents