Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.Views package

Subpackages

Submodules

duHast.Revit.Views.delete module

This module contains a number of helper functions relating to deleting Revit views.

duHast.Revit.Views.delete.delete_views(doc, view_rules, collector_views)

Deletes views based on view rules supplied.

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

  • view_rules (list of lists, where each inner list has the format [parameter name, condition test method, value to test against]) – Rules used to check whether a view should be deleted. Rules are based on parameters attached to views and their values.

  • collector_views (Autodesk.Revit.DB.FilteredElementCollector) – A filtered element collector containing views.

Returns:

Result class instance. - result (bool): True if all views were deleted, otherwise False. - message (str): Deletion status.

Return type:

Result

duHast.Revit.Views.delete.delete_views_not_on_sheets(doc, filter)

Deletes all views not placed on sheets, including schedules and legends matching the given filter.

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

  • filter (function(view) -> bool) – A function that checks whether a view should be deleted.

Returns:

Result class instance. - result (bool): True if all views were deleted, otherwise False. - message (str): Deletion status.

Return type:

Result

duHast.Revit.Views.delete.delete_unused_elevation_view_markers(doc)

Deletes all unused elevation markers (no elevation is created by the marker).

Parameters:

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

Returns:

Result class instance. - result (bool): True if all unused elevation markers were deleted, otherwise False. - message (str): Deletion status.

Return type:

Result

duHast.Revit.Views.delete.delete_sheets(doc, view_rules, collector_views)

Deletes sheets based on rules.

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

  • view_rules (array in format [parameter name, condition test method, value to test against) – A set of rules. If view matches rule it will be deleted.

  • collector_views (Autodesk.Revit.DB.FilteredElementCollector) – A filtered element collector containing view instances.

Returns:

Result class instance. - .status True if all sheets matching filter where deleted. Otherwise False. - .message will contain deletion status.

Return type:

Result

duHast.Revit.Views.delete.delete_all_sheets(doc)

Deletes all sheets in a model

Parameters:

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

Returns:

Result class instance. - .status True if all sheets where deleted. Otherwise False. - .message will contain deletion status.

Return type:

Result

duHast.Revit.Views.element_overrides module

This module contains a number of helper functions relating to by element in view overrides.

duHast.Revit.Views.element_overrides.overwrite_element_graphics_in_view(doc, view, elements, override_graphics_settings=None)

Overwrite the graphics of elements in a view.

Note: If None is passed as the override_graphics_settings parameter, the default settings will be used to remove any overrides on the elements.

Parameters:
  • doc (Document) – The Revit document.

  • view (View) – The view in which the elements are located.

  • elements (list) – The elements to overwrite the graphics for.

  • override_graphics_settings (Autodesk.Revit.DB.OverrideGraphicSettings) – The override settings to apply to the elements.

Returns:

A result object.

Return type:

Result

duHast.Revit.Views.elevation_view_create module

This module contains a number of helper functions relating to Revit elevation view creation.

duHast.Revit.Views.elevation_view_create.create_elevation_views(doc, view_type, view_marker_location, scale, view_index_list=[], view_names=[], view_plan=None, phasing=None, view_crop=None, view_crop_visible=True, transaction_manager=<function in_transaction_with_failure_handling>)

Creates an elevation marker and associated elevation views in the Revit document.

This function creates an elevation marker at the specified location and, if defined through their indicis, creates elevation views on that marker. It sets various properties for the views, such as names, phasing, and crop box settings. The function can handle transactions and failure handling as specified.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The Revit document where the elevation marker and views will be created.

  • view_type (Autodesk.Revit.DB.ViewFamilyType) – The type of the elevation view to be created.

  • view_marker_location (Autodesk.Revit.DB.XYZ) – The location where the elevation marker will be placed.

  • scale (int) – The initial scale of the elevation views.

  • view_index_list (list of int, optional) – List of indices specifying which elevation views on the marker to create, defaults to an empty list.

  • view_names (list of str, optional) – List of names to assign to the created elevation views, defaults to an empty list.

  • view_plan (Autodesk.Revit.DB.ViewPlan, optional) – The plan view to associate with the elevation views, defaults to None. Only required if elevation views are to be created (not just a marker)

  • phasing (Autodesk.Revit.DB.Element, optional) – The phase to assign to the new views, defaults to None.

  • view_crop (Autodesk.Revit.DB.BoundingBoxXYZ or Autodesk.Revit.DB.CurveLoop, optional) – The crop box or loop to apply to the views, defaults to None.

  • view_crop_visible (bool, optional) – Flag indicating whether the crop box should be visible, defaults to True.

  • transaction_manager (function, optional) – The transaction manager to handle transactions and failure handling, defaults to in_transaction_with_failure_handling. Set to None if a transaction is already running.

Raises:

ValueError – If the elevation marker or views cannot be created.

Returns:

A Result object containing the outcome of the elevation creation process.

Return type:

Result

duHast.Revit.Views.filters module

This module contains a number of helper functions relating to Revit view filters.

duHast.Revit.Views.filters.get_all_filters(doc)

Gets all filters in document as a collector

Parameters:

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

Returns:

A filtered Element collector containing Autodesk.Revit.DB.ParameterFilterElement

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Views.filters.get_all_filter_ids(doc)

Gets all view filter ids in document

Parameters:

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

Returns:

All view filter Id’s which are in the model.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.filters.get_filter_by_name(doc, filter_name)

Retrieves a filter by its name from the current Revit model document.

Args:

doc (Revit Document): The current Revit model document. filter_name (str): The name of the filter to be retrieved.

Returns:

Filter: The filter with the specified name, if found. None: If no filter with the specified name is found.

duHast.Revit.Views.filters.get_filter_ids_from_view_by_filter(view, unique_list)

Returns past in list of filter id’s plus new unique filter id’s from view (if not already in list past in)

Parameters:
  • view (Autodesk.Revit.DB.View) – The view of which to get the filters from.

  • unique_list (list of Autodesk.Revit.DB.ElementId) – List containing view filters

Returns:

List containing past in view filters and new view filters.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.filters.is_filter_applied_to_view(view, filter)

Checks if a filter is already applied to a view in Autodesk Revit.

Args:

view (Autodesk.Revit.DB.View): The view object to check if the filter is applied. filter (Autodesk.Revit.DB.Filter): The filter object to check if it is applied to the view.

Returns:

bool: True if the filter is applied to the view, False otherwise.

duHast.Revit.Views.filters.get_filters_from_templates(doc)

Gets all filter id’s used in view templates only. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List containing filter Id’s. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.filters.get_filter_ids_from_views_without_template(doc, filter_by_type)

Gets all filter id’s from views which dont have a template applied and match a given view type. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param filter_by_type: list of view types of which the filters are to be returned. :type filter_by_type: list of Autodesk.Revit.DB.ViewType :return: List containing filter Id’s. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.filters.get_all_unused_view_filters(doc)

Gets id’s of all unused view filters in a model :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List containing filter Id’s. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.filters.apply_filter_to_view(doc, view, filter)

Applies a filter to a view in Autodesk Revit.

Args:

doc (Autodesk.Revit.DB.Document): The document object representing the Revit model. view (Autodesk.Revit.DB.View): The view object to which the filter should be applied. filter (Autodesk.Revit.DB.Filter): The filter object that should be applied to the view.

Returns:

duHast.Utilities.Objects.result.Result: The result object containing the outcome of applying the filter to the view. The result attribute of the result object indicates whether the filter was applied successfully or not. The messages attribute of the result object contains any additional messages related to the application of the filter.

duHast.Revit.Views.legends module

This module contains a number of helper functions relating to Revit legends.

duHast.Revit.Views.legends.get_view_legends(doc)

Get all view legends in a model.

Parameters:

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

Returns:

All view legends in the model

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.legends.get_view_legends_not_placed(doc)

Returns all unplaced legend views

Parameters:

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

Returns:

All view legends in the model not on a sheet

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.plan_view_create module

This module contains a number of helper functions relating to Revit plan view creation.

duHast.Revit.Views.plan_view_create.create_view_plan(doc, level, view_type, view_name=None, phasing=None, view_crop=None, view_crop_visible=True)

Creates a new plan view in the Revit document.

This function creates a new plan view in the specified Revit document, sets its properties, and handles any errors that occur during the process. The function supports setting the view name, phasing, and crop box properties.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The Revit document where the view will be created.

  • level (Autodesk.Revit.DB.Level) – The level at which the view will be created.

  • view_type (Autodesk.Revit.DB.ViewFamilyType) – The type of the view to be created.

  • view_name (str, optional) – The name to assign to the new view, defaults to None.

  • phasing (Autodesk.Revit.DB.Element, optional) – The phase to assign to the new view, defaults to None.

  • view_crop (Autodesk.Revit.DB.BoundingBoxXYZ or Autodesk.Revit.DB.CurveLoop, optional) – The crop box or loop to apply to the view, defaults to None.

  • view_crop_visible (bool, optional) – Flag indicating whether the crop box should be visible, defaults to True.

Returns:

A Result object containing the outcome of the view creation process.

Return type:

Result

duHast.Revit.Views.referencing module

This module contains a number of helper functions relating to Revit view referencing.

duHast.Revit.Views.referencing.deprecated__get_all_call_out_types_by_category(doc)

this will return an EMPTY filtered element collector of all call out types in the model in Revit 2019

duHast.Revit.Views.referencing.deprecated__get_all_reference_view_types_by_category(doc)

this will return an EMPTY filtered element collector of all reference view types in the model in Revit 2019

duHast.Revit.Views.referencing.deprecated__get_all_call_out_type_ids_by_category(doc)

this will return an EMPTY filtered element collector of all call out type ids in the model

duHast.Revit.Views.referencing.deprecated__get_all_reference_view_type_ids_by_category(doc)

this will return an EMPTY filtered element collector of all reference view types in the model

duHast.Revit.Views.referencing.get_all_call_out_heads_by_category(doc)

Gets a filtered element collector of all callOut Head symbol (types) in the model.

Parameters:

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

Returns:

A filtered element collector containing call out head symbols.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Views.referencing.get_all_elevation_heads_by_category(doc)

Gets a filtered element collector of all elevation symbols (types) in the model.

Parameters:

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

Returns:

A filtered element collector containing elevation symbols.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Views.referencing.get_all_section_heads_by_category(doc)

Gets a filtered element collector of all section symbols (types) in the model.

Parameters:

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

Returns:

A filtered element collector containing section symbols.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Views.referencing.get_all_view_continuation_markers_by_category(doc)

Gets a filtered element collector of all view continuation symbols (types) in the model.

Parameters:

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

Returns:

A filtered element collector containing Continuation Marker symbols.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Views.referencing.get_all_reference_view_elements_by_category(doc)

Gets filtered element collector of all reference view elements in the model.

Parameters:

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

Returns:

A filtered element collector containing reference view elements.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Views.referencing.VIEW_REFERENCE_PARAMETER_DEF_NAMES = [Autodesk.Revit.DB.BuiltInParameter.ELEVATN_TAG, Autodesk.Revit.DB.BuiltInParameter.CALLOUT_TAG, Autodesk.Revit.DB.BuiltInParameter.SECTION_TAG]

contains the builtin parameter definitions for Call out type ids, section type ids, elevation type ids

duHast.Revit.Views.referencing.VIEW_TAG_SYMBOL_PARAMETER_DEF = [Autodesk.Revit.DB.BuiltInParameter.CALLOUT_ATTR_HEAD_TAG, Autodesk.Revit.DB.BuiltInParameter.ELEV_SYMBOL_ID, Autodesk.Revit.DB.BuiltInParameter.SECTION_ATTR_HEAD_TAG, Autodesk.Revit.DB.BuiltInParameter.SECTION_ATTR_TAIL_TAG, Autodesk.Revit.DB.BuiltInParameter.REFERENCE_VIEWER_ATTR_TAG]

contains the builtin parameter definitions for call out symbol tag ids, section symbol tag ids, elevation symbol tag ids

duHast.Revit.Views.referencing.VIEW_REF_CATEGORY_FILTER = [Autodesk.Revit.DB.BuiltInCategory.OST_CalloutHeads, Autodesk.Revit.DB.BuiltInCategory.OST_ElevationMarks, Autodesk.Revit.DB.BuiltInCategory.OST_SectionHeads, Autodesk.Revit.DB.BuiltInCategory.OST_ReferenceViewerSymbol]

category filter for all view ref categories

duHast.Revit.Views.referencing.get_reference_type_ids_from_view_type(view_type)

Gets all reference type ids used in view type.

Parameters:

view_type (Autodesk.Revit.DB.ViewType) – The view type.

Returns:

dictionary, key: BuiltinParameterDefinition, value: id of a tag

Return type:

dic{Autodesk.Revit.DB.BuiltinParameterDefinition:[Autodesk.Revit.DB.ElementId]}

duHast.Revit.Views.referencing.get_used_view_reference_type_id_data(doc)

Gets all view references types in use in the model in a dictionary.

Parameters:

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

Returns:

key is the reference tag type: call out, section or elevation, values are the type ids in use

Return type:

dictionary {reference tag type: list Autodesk.Revit.DB.ElementIds}

duHast.Revit.Views.referencing.get_all_view_reference_type_id_data(doc)

Gets all view references types available in the model in a dictionary.

Parameters:

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

Returns:

key is the reference type: call out, section or elevation, values are the type ids in use

Return type:

dictionary {reference tag type: list Autodesk.Revit.DB.ElementIds}

duHast.Revit.Views.referencing.get_all_view_reference_type_id_data_as_list(doc)

Gets all view references type ids available in the model.

Parameters:

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

Returns:

A list of element ids representing view reference types

Return type:

list Autodesk.Revit.DB.ElementIds

duHast.Revit.Views.referencing.get_all_view_continuation_type_ids(doc)

Gets all view continuation type ids available in the model.

Parameters:

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

Returns:

List of view continuation type ids.

Return type:

list Autodesk.Revit.DB.ElementIds

duHast.Revit.Views.referencing.get_used_view_continuation_type_ids(doc)

returns all view continuation types available in the model

duHast.Revit.Views.referencing.get_all_view_reference_symbol_ids(doc)

Gets the ids of all view reference family symbols(types) in the model.

Parameters:

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

Returns:

List of view reference family symbols(types) ids.

Return type:

list Autodesk.Revit.DB.ElementIds

duHast.Revit.Views.referencing.get_symbol_ids_from_type_ids(doc, view_ref_types_ids)

‘Gets the ids of all view family symbols(types) from given view ref types or continuation types the model.

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

  • view_ref_types_ids (list Autodesk.Revit.DB.ElementId) – list of ids representing view reference types or continuation types

Returns:

List of ids of all view family symbols(types).

Return type:

list Autodesk.Revit.DB.ElementId

duHast.Revit.Views.referencing.get_used_view_reference_and_continuation_marker_symbol_ids(doc)

Get the ids of all view reference symbols(types) and view continuations symbols (types) used by view reference types and view continuation types in the model.

Parameters:

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

Returns:

List of ids of all view family symbols(types).

Return type:

list Autodesk.Revit.DB.ElementId

duHast.Revit.Views.referencing.get_nested_family_marker_names(doc, used_ids)

Gets nested family names from provided symbols.

  • Retrieves a families from the symbols provided.

  • Opens the family document and extracts the names off all nested families within.

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

  • used_ids (list of Autodesk.Revit.DB.ElementId) – List of symbol ids.

Returns:

List of all unique nested family names.

Return type:

list str

duHast.Revit.Views.schedules module

This module contains a number of helper functions relating to Revit view schedules.

duHast.Revit.Views.schedules.get_schedule_ids_on_sheets(doc)

Gets view ids of all schedules with instances placed on a sheet

Parameters:

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

Returns:

List containing schedule Id’s.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.schedules.get_schedules_not_on_sheets(doc)

Gets all schedules without an instance placed on a sheet.

Parameters:

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

Returns:

list of schedules without a sheet schedule instance.

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.schedules.get_schedule_instance_on_sheet(doc, sheet)

Returns a list containing all schedule sheet instances on a sheet.

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

  • sheet (Autodesk.Revit.DB.ViewSheet) – A sheet

Returns:

a list of schedule sheet instances or empty list if none found

Return type:

[Autodesk.revit.DB.ScheduleSheetInstance]

duHast.Revit.Views.schedules_revision_filter module

This module contains a number of helper functions relating to Revit view schedules.

duHast.Revit.Views.schedules_revision_filter.filter_revision_schedules(view)

Checks whether a view is a revision schedule. (not required…schedules have a property flag!!)

Parameters:

view (Autodesk.Revit.DB.View) – The view to check.

Returns:

True if the view name starts with ‘<’, otherwise False

Return type:

bool

duHast.Revit.Views.schedules_revision_filter.filter_schedules(view)

Checks if the view is of type schedule. If so it returns true, otherwise false

Parameters:

view (Autodesk.Revit.DB.View) – the view

Returns:

True if view is a schedule, otherwise false.

:rtype:bool

duHast.Revit.Views.sheets module

This module contains a number of helper functions relating to Revit view sheets.

duHast.Revit.Views.sheets.get_sheets_by_filters(doc, view_rules=None)

Gets sheets matching filters provided :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param view_rules: A set of rules. If sheet matches rule it will be returned. Defaults to None which will return all sheets. :type view_rules: array in format [parameter name, condition test method, value to test against], optional

Returns:

Views matching filter

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.sheets.get_all_sheets(doc)

Gets all sheets in a model :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: list of sheet views :rtype: list of Autodesk.Revit.DB.View

duHast.Revit.Views.sheets.get_sheet_rev_by_sheet_number(doc, sheet_number)

Returns the revision of a sheet identified by its number. Default value is ‘-‘.

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

  • sheet_number (str) – The number of the sheet of which the revision is to be returned.

Raise:

Any exception will need to be managed by the function caller.

Returns:

The sheet’s current revision value. If no matching sheet is found, ‘-’ is returned.

Return type:

str

duHast.Revit.Views.sheets.get_sheet_rev_by_sheet_name(doc, sheet_name)

Returns the revision of a sheet identified by its name. Default value is ‘-‘.

Since multiple sheets can have the same name, it will return the revision of the first sheet matching the name.

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

  • sheet_name (str) – The name of the sheet of which the revision is to be returned.

Raise:

Any exception will need to be managed by the function caller.

Returns:

The sheet’s current revision value. If no matching sheet is found, ‘-’ is returned.

Return type:

str

duHast.Revit.Views.sheets.get_sheet_num_to_elem_dict(rvt_doc)

Get a dictionary of sheet numbers and sheets :param rvt_doc: The Revit document to get the sheets from :type rvt_doc: Document :return: A dictionary of sheet numbers and sheets :rtype: dict

duHast.Revit.Views.sheets.get_title_block_from_sheet(doc, sheet)

Returns the first title block located on a sheet or None if there is none placed.

Args:

doc (Autodesk.Revit.DB.Document): Current Revit model document. sheet (Autodesk.Revit.DB.ViewSheet):The sheet of which to return the title block from

Returns:

Autodesk.Revit.DB.FamilyInstance: The first title block instance on a sheet or None.

duHast.Revit.Views.sheets_create module

This module contains a number of helper functions relating to Revit sheet creation.

duHast.Revit.Views.sheets_create.create_sheet(doc, sheet_number, sheet_name, title_block_family_symbol, additional_properties={})

Creates a revit sheet.

Parameters:
  • doc (Document) – The Revit document.

  • sheet_number (str) – The new sheet number

  • sheet_name (str) – The new sheet name

  • title_block_family_symbol (Autodesk.Revit.DB.FamilySymbol) – The title block type to be used

  • additional_properties (dict, optional) – a dictionary representing parameter names on the new sheet and their value, defaults to {}

Raises:
  • ValueError – If sheet number is not a string

  • ValueError – If sheet name is not a string

  • ValueError – If title_block_family_symbol is not a Autodesk.Revit.DB.FamilySymbol

  • ValueError – If sheet failed to create

Returns:

Result class instance.

  • .status True if sheet was created and parameters where updated successfully. Otherwise False.

  • .message will contain stats.

  • .result will be a list containing the sheet instance created.

Return type:

Result

duHast.Revit.Views.templates module

This module contains a number of helper functions relating to Revit view templates.

duHast.Revit.Views.templates.get_view_templates(doc)

Get all view templates in a model.

Parameters:

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

Returns:

All view templates in the model

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.templates.get_view_templates_ids(doc)

Get all view template ids in a model

Parameters:

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

Returns:

All view templates Id’s in the model

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.templates.get_view_template_which_allow_graphical_overrides(doc)

Returns a list of view template which allow graphical overrides to be applied.

Parameters:

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

Returns:

list

Return type:

[Autodesk.Revit.DB.View]

duHast.Revit.Views.templates.get_used_view_templates_ids(doc)

Gets ids of view templates used in views in the model only :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: All used view templates Id’s in the model :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.templates.get_view_template_by_name(doc, view_template_name)

Returns a view template by its name.

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

  • view_template_name (str) – The view template name.

Returns:

A view template if name matches, otherwise None

Return type:

Autodesk.Revit.DB.View

duHast.Revit.Views.templates.get_default_view_type_template_ids(doc)

Gets view template Id’s used as default by view types

Parameters:

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

Returns:

All view templates Id’s which are used as default in view types in the model

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.templates.get_all_used_view_template_ids(doc)

Get all used view template Id’s.

Templates can either be: - used as default by view types - used by a view

Parameters:

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

Returns:

All view templates Id’s which are used in the model.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.templates.get_template_ids_which_can_have_filters(doc, filter_by_type)

Get all templates in a model of given type

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

  • filter_by_type (list of Autodesk.Revit.DB.ViewType) – List of view types of which to return view templates from

Returns:

All view templates in the model

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.templates.get_all_unused_view_template_ids(doc)

Gets all view template Id’s not used by view types or by views :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: All view templates Id’s which are not used in the model. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.views module

This module contains a number of helper functions relating to Revit views.

duHast.Revit.Views.views.get_view_types(doc)

Returns all view family types in a model :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A filtered element collector. :rtype: Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Views.views.get_view_type_ids(doc)

Returns all view family type ids in a model

Parameters:

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

Returns:

ids of view family types

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.views.get_views_of_type(doc, view_type)

Gets all views in a model of a given type. Excludes templates.

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

  • view_type (Autodesk.Revit.DB.ViewType) – Filter: the view type

Returns:

list of views

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.views.get_viewport_on_sheets(doc, sheets)

Get all view ports on sheets provided.

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

  • sheets (list of Autodesk.Revit.DB.ViewSheet) – list of sheets of which to return the view ports from.

Returns:

list of view ports

Return type:

list of Autodesk.Revit.DB.Viewport

duHast.Revit.Views.views.get_views_in_model(doc, filter)

Gets all views in a model which are matching a filter and are:

  • not template views

  • not system browser

  • not project browser

  • not undefined

  • not Internal

  • not sheets

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

  • filter (func(view) returning a bool) – function checking view

Returns:

list of views

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.views.get_views_not_on_sheet(doc)

Gets all views not placed on a sheet. (Excludes schedules)

Parameters:

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

Returns:

A list of views which are currently not placed on a sheet.

Return type:

list of Autodesk.Revit.DB.View

duHast.Revit.Views.views.get_view_phase_id(view)

Get the views phase id.

Note if view does not support phase id and Invlaid ElementId (-1) is returned

Parameters:

view (Autodesk.Revit.DB.View) – The view of which to return the phase id

Returns:

An element id representing the phase id. If view does not support phases then an Invalid id (-1) will be returned.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.views.get_area_scheme_of_view(doc, view)

Returns the area scheme an area plan is associated with.

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

  • view (Autodesk.Revit.DB.View) – The view of which to return the area scheme

Returns:

The area scheme if the view is of type AreaPlan otherwise None

Return type:

str or None

duHast.Revit.Views.views_crop module

View crop utilities.

duHast.Revit.Views.views_crop.get_view_crop(view)

Get the crop region loops of a view.

This method returns a representation of the boundaries of the currently active crop for the associated view. If the view crop has a non-rectangular shape, the method returns that shape. Otherwise, if the view crop has been split, the method returns the multiple rectangular boundaries visible in the crop - note that this does not reflect any offsets that may have been applied to the boundary regions. If the crop is not split, this returns a single rectangle representing the crop. All coordinates are in the coordinate frame of the view.

Parameters:

view (Autodesk.Revit.DB.View) – The view to get the crop region from.

Returns:

The crop region of the view.

Return type:

[Autodesk.Revit.DB.CurveLoop]

duHast.Revit.Views.views_crop.apply_view_crop_without_transaction_wrapper(view, crop_loop)

Apply a crop region to a view.

This method sets the crop region of the view to the specified crop loops.

Parameters:
  • view (Autodesk.Revit.DB.View) – The view to apply the crop region to.

  • crop_loops (Autodesk.Revit.DB.CurveLoop) – The crop loop to apply to the view.

Returns:

The result of the operation.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.views_crop.apply_view_crop(doc, view, crop_loop)

Apply a crop region to a view.

This method sets the crop region of the view to the specified crop loops.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The document containing the view.

  • view (Autodesk.Revit.DB.View) – The view to apply the crop region to.

  • crop_loops (Autodesk.Revit.DB.CurveLoop) – The crop loop to apply to the view.

Returns:

The result of the operation.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.views_crop.apply_view_bounding_box_crop_without_transaction_wrapper(view, bbox)

Apply a crop region to a view.

This method sets the crop region of the view to the specified crop loops.

Parameters:
  • view (Autodesk.Revit.DB.View) – The view to apply the crop region to.

  • bbox – The bounding box to apply as crop to the view.

Returns:

The result of the operation.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.views_crop.apply_view_bounding_box_crop(doc, view, bbox)

Apply a crop region to a view.

This method sets the crop region of the view to the specified crop loops.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The document containing the view.

  • view (Autodesk.Revit.DB.View) – The view to apply the crop region to.

  • bbox – The bounding box to apply as crop to the view.

Returns:

The result of the operation.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.views_purge_unused module

Views purge unused utilities.

duHast.Revit.Views.views_purge_unused.get_unused_continuation_marker_type_ids_for_purge(doc)

Gets all unused view continuation type ids in model for purge. This method can be used to safely delete all unused view continuation marker types. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids. :rtype: list Autodesk.Revit.DB.ElementId

duHast.Revit.Views.views_purge_unused.is_nested_family_symbol(doc, id, nested_family_names)

Returns true if symbol belongs to family in list past in. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param id: The element id of a symbol. :type id: Autodesk.Revit.DB.ElementId :param nested_family_names: list of family names know to be nested families. :type nested_family_names: list str :return: True if family name derived from symbol is in list past in, otherwise False. :rtype: bool

duHast.Revit.Views.views_purge_unused.get_unused_view_ref_and_continuation_marker_symbol_ids(doc)

Gets the ids of all view reference symbols(types) and view continuation symbols (types) not used in the model. Not used: These symbols are not used in any view reference types, or nested in any symbols used in view reference types. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids. :rtype: list Autodesk.Revit.DB.ElementId

duHast.Revit.Views.views_purge_unused.get_unused_view_ref_and_continuation_marker_families_for_purge(doc)

Gets the ids of all view reference symbols(types) ids and or family ids not used in the model for purging. This method can be used to safely delete all unused view reference and continuation marker family symbols or families. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids. :rtype: list Autodesk.Revit.DB.ElementId

duHast.Revit.Views.views_purge_unused.get_unused_view_reference_type_ids_for_purge(doc)

Gets all unused view references type ids in model for purge. This method can be used to safely delete all unused view reference types. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids. :rtype: list Autodesk.Revit.DB.ElementId

duHast.Revit.Views.views_purge_unused.get_used_view_type_ids(doc)

Returns all view family types in use in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: ids of view family types in use :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.views_purge_unused.get_unused_view_type_ids(doc)

Returns all unused view family types in the model :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: ids of view family types not in use :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.visibility_graphics module

This module contains a number of helper functions relating to Revit visibility graphics settings.

duHast.Revit.Views.visibility_graphics.import_graphic_overrides(file_path, call_back)

Reads JSON data from a file and converts it into a dictionary of ViewGraphicsSettings objects.

Args:

file_path (str): The fully qualified file path of the JSON file. call_back (function): A callback function to update the progress of the data import.

Returns:

dict: A dictionary of ViewGraphicsSettings objects, where the view name is the key and the ViewGraphicsSettings object is the value.

duHast.Revit.Views.visibility_graphics.check_line_patterns_are_in_model(doc, line_pattern_data)

Check whether the line patterns used in the line_pattern_data exist in the Revit model.

Args:

doc (Revit Document): The Revit document object. line_pattern_data (dictionary): A dictionary containing line pattern data.

Returns:

Result: A Result object containing the results of the line pattern check.

duHast.Revit.Views.visibility_graphics.check_fill_patterns_are_in_model(doc, fill_pattern_data)

Check whether all fill patterns used in the fill_pattern_data exist in the Revit model.

Args:

doc (Revit Document): The Revit document object. fill_pattern_data (dict): A dictionary containing fill pattern data.

Returns:

Result: A Result object containing the results of the fill pattern check.

duHast.Revit.Views.visibility_graphics.check_all_line_and_fill_pattern_in_model(doc, view_overrides_data)

Check whether all line patterns and fill patterns used in the view_overrides_data exist in the model.

Args:

doc (Revit Document): The Revit document object. view_overrides_data (dict): A dictionary containing view overrides data.

Returns:

Result: A Result object containing the results of the line pattern and fill pattern checks.

duHast.Revit.Views.visibility_graphics.get_matching_templates(doc, view_overrides_data)

Returns a dictionary containing the view templates that match the view names specified in the view_overrides_data dictionary.

Args:

doc (Autodesk.Revit.DB.Document): The current Revit model document. view_overrides_data (dict): A dictionary containing view override data. The keys are view names and the values are objects of type ViewOverrideData.

Returns:

dict: A dictionary containing the view templates that match the view names specified in the view_overrides_data dictionary. The keys are view names and the values are tuples containing the view template and the corresponding view override data.

duHast.Revit.Views.visibility_graphics.apply_override_to_view(doc, view, view_override)

Apply graphic and filter overrides to a Revit view.

Args:

doc (Revit Document): The current Revit document. view (Revit View): The view to apply the overrides to. view_override (ViewOverride): An object containing the desired graphic and filter overrides.

Returns:

Result: A result object containing the status of the override application, any error messages, and additional information.

duHast.Revit.Views.visibility_graphics.apply_overrides_to_views(doc, view_data)

Applies graphic and filter overrides to multiple views in a Revit document.

Args:

doc (Revit Document): The current Revit document. view_data (dict): A dictionary where the keys are the names of the views and the values are lists containing the Revit view object and the view override object.

Returns:

Result: A result object containing the status of the override application, any error messages, and additional information.

duHast.Revit.Views.visibility_graphics.apply_overrides_from_file(doc, file_path)

Applies graphic and filter overrides to multiple views in a Revit document based on data imported from a JSON file.

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

  • file_path (str) – The fully qualified file path of the JSON file containing the view override data.

Returns:

A result object containing the status of the override application, any error messages, and additional information.

Return type:

Result

Example:

Example Usage: >>> result = apply_overrides_from_file(doc, file_path) >>> if result.status: … print(“Overrides applied successfully.”) >>> else: … print(“Failed to apply overrides:”, result.message)

duHast.Revit.Views.visibility_graphics_categories module

This module contains a number of helper functions relating to Revit category overrides in views.

duHast.Revit.Views.visibility_graphics_categories.get_categories_and_subcategories_from_model(doc)

Returns all categories and sub categories in a model in a dictionary:

Dictionary:

  • key is same format as list: main category name::sub category name

  • value is a named tuple category_storage instance

Parameters:

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

Returns:

dictionary of categories

Return type:

{str:category_storage}

duHast.Revit.Views.visibility_graphics_categories.update_category_override_from_view(view, category_storage_instance)

Populates the category_override and is_category_hidden field of a ‘category_storage’ instance based on the view past in.

Parameters:
  • view (Autodesk.Revit.DB.View) – The view from which the category override is to be used.

  • category_storage_instance (RevitCategoryOverride) – An instances of revit category storage containing no view specific information.

Returns:

An updated instances of revit category storage now containing the override, category visibility flags.

Return type:

RevitCategoryOverride

duHast.Revit.Views.visibility_graphics_categories.get_category_overrides_from_view(view, category_storage_instances)

Populates the category_override and is_category_hidden fields of a list of ‘category_storage’ instances based on the view past in.

Parameters:
  • view (Autodesk.Revit.DB.View) – The view from which the category override is to be used.

  • category_storage_instances ([RevitCategoryOverride]) – A list of instances of class ‘RevitCategoryOverride’

Returns:

A list of instances of revit category storage now containing the override, category visibility flags.

Return type:

[RevitCategoryOverride]

duHast.Revit.Views.visibility_graphics_categories.apply_graphic_override_to_view(doc, view, category_storage_instances)

Applies graphic override(s) to a single view

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

  • view (Autodesk.Revit.DB.View) – The view on which the category override is to be used.

  • category_storage_instances ([RevitCategoryOverride]) – A list of instances of class ‘RevitCategoryOverride’

return:

Result class instance.

  • Apply override status returned in result.status. False if an exception occurred, otherwise True.

  • result.message will contain message ‘Successfully set category override…’ for each override applied.

  • result.result will be an empty list

On exception:

  • result.status (bool) will be False.

  • result.message will contain the exception message.

  • result.result will be an empty list.

Return type:

Result

duHast.Revit.Views.visibility_graphics_filters module

This module contains a number of helper functions relating to Revit filter overrides in views.

duHast.Revit.Views.visibility_graphics_filters.get_filters_from_model(doc)

Retrieves all filters in a Revit model and stores them in a dictionary.

Parameters:

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

Returns:

A dictionary containing the filters in the model as RevitFilterOverride objects. The keys of the dictionary are the filter names.

Return type:

{str: RevitFilterOverride}

duHast.Revit.Views.visibility_graphics_filters.update_filter_override_from_view(view, filter_storage_instance)

Populates the filter_override and is_filter_visible and is_filter_enabled field of a ‘RevitFilterOverride’ instance based on the view past in.

Parameters:
  • view (Autodesk.Revit.DB.View) – The view from which the filter override is to be used.

  • filter_storage_instance (RevitFilterOverride) – An instances of revit filter storage containing no view specific information.

Returns:

An updated instances of revit filter storage now containing the override, filter visibility and filter enabled flags.

Return type:

RevitFilterOverride

duHast.Revit.Views.visibility_graphics_filters.get_filter_overrides_from_view(view, filter_storage_instances)

Populates the category_override and is_category_hidden fields of a list of ‘category_storage’ instances based on the view past in.

Parameters:
  • view (Autodesk.Revit.DB.View) – The view from which the category override is to be used.

  • filter_storage_instances ([RevitFilterOverride]) – A list of instances of class ‘RevitFilterOverride’

Returns:

A list of instances of class ‘RevitFilterOverride’ where the override, filter visibility and filter enabled flags have been updated dependent on the view.

Return type:

[RevitFilterOverride]

duHast.Revit.Views.visibility_graphics_filters.apply_filter_override_to_view(doc, view, filter_storage_instances, add_filter_if_not_present=True)

Applies filter override(s) to a single view

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

  • view (Autodesk.Revit.DB.View) – The view on which the category override is to be used.

  • filter_storage_instances ([RevitFilterOverride]) – A list of storage class instances.

Returns:

Result class instance.

  • Apply override status returned in result.status. False if an exception occurred, otherwise True.

  • result.message will contain message ‘Successfully set category override…’ for each override applied.

  • result.result will be an empty list

On exception:

  • result.status (bool) will be False.

  • result.message will contain the exception message.

  • result.result will be an empty list.

Return type:

Result

duHast.Revit.Views.visibility_graphics_filters.view_has_filter(view, filter_to_check_id)

Checks if a specific filter is applied to a given view.

Parameters:
  • view (Autodesk.Revit.DB.View) – The view object to check for applied filters.

  • filter_to_check_id (Autodesk.Revit.DB.ElementId) – The ID of the filter to check if it is applied.

Returns:

A boolean value indicating whether the specified filter is applied to the view.

Return type:

bool

duHast.Revit.Views.visibility_graphics_filters.add_filter_to_view(doc, filter, view)

Adds a filter to a view in Autodesk Revit.

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

  • filter (Autodesk.Revit.DB.ParameterFilterElement) – The filter to be added to the view.

  • view (Autodesk.Revit.DB.View) – The view to which the filter will be added.

Returns:

An instance of the Result class that contains the result of the filter addition. The result attribute is True if the filter was added successfully, otherwise False. The message attribute contains additional information about the result.

Return type:

Result

duHast.Revit.Views.visibility_graphics_filters.remove_filter_from_view(doc, filter, view)

Removes a filter from a view.

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

  • filter (Autodesk.Revit.DB.ParameterFilterElement) – The filter to be removed from the view.

  • view (Autodesk.Revit.DB.View) – The view (can be a view template too!)

Returns:

Result class instance.

  • .result True if filter was removed successfully or if filter was not applied or if view does not support filters, otherwise False

  • .message will contain deletion status.

  • . result (empty list)

on exception:

  • .result Will be False

  • .message will contain exception message.

  • . result (empty list)

Return type:

Result

Module contents