Sample Code Revit Batch Processor 1.1.16 documentation

Contents:

This Page

duHast.Revit.Views package

Subpackages

Submodules

duHast.Revit.Views.annotation_crop module

Helper functions to switch a view’s annotation crop on or off and place its edges.

duHast.Revit.Views.annotation_crop.set_annotation_crop_without_transaction_wrapper(view, active, offsets=None)

Switches the annotation crop of a view on or off and, when on, places its four edges.

The offsets are from the edges of the view crop and in view units, which is paper: Revit keeps them in feet on paper, so they hold at any view scale. The annotation crop can not be smaller than the view crop (the least offset is 1/8 inch on paper); a smaller offset is raised to it by Revit’s own check, which this reports.

Changing the model: this needs to run inside a transaction.

Parameters:
  • view (Autodesk.Revit.DB.View) – The plan or elevation view.

  • active (bool) – Whether the annotation crop is on.

  • offsets (dict, optional) – The edges as {“left”, “right”, “top”, “bottom”} in mm on paper; only used when active.

Returns:

Result class instance.

Return type:

Result

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 module

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

duHast.Revit.Views.elevation.get_marker_and_index_of_view(doc, view)

Get the elevation marker hosting an elevation view and the index the view has on it.

The index alone does not say which marker it belongs to: a room with two markers has an index 0 on each, so the marker is needed to know which views belong together.

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

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

Returns:

The marker and the index, or (None, None) if the view is not on a marker.

Return type:

(Autodesk.Revit.DB.ElevationMarker, int) or (None, None)

duHast.Revit.Views.elevation.get_view_index_on_marker(doc, view)

Get the index of the view on the elevation marker. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param view: Revit view. :type view: Autodesk.Revit.DB.View

Returns:

Index of the view on the elevation marker. None if not found.

Return type:

int or None

duHast.Revit.Views.elevation.get_marker_location(marker, doc=None)

Get where an elevation marker sits.

Revit gives an elevation marker no point of its own: its Location is the bare Location class (it can only be moved and rotated), and it has no bounding box outside a plan view. So, when it is not a LocationPoint, and a document is given, the centre of the marker’s circle is worked out from its view pointers (see get_marker_centre_from_pointers).

Parameters:
  • marker (Autodesk.Revit.DB.ElevationMarker) – The elevation marker.

  • doc (Autodesk.Revit.DB.Document, optional) – The document the marker is in, defaults to None (only a LocationPoint is then answered).

Returns:

The marker’s point in Revit’s internal units (feet), None if it cannot be found.

Return type:

Autodesk.Revit.DB.XYZ or None

duHast.Revit.Views.elevation.get_pointers_of_marker(doc, marker)

The view pointers of an elevation marker: its dependent elements of the Viewers category (OST_Viewers, which Revit names “Views”), as ids. Moving one moves the elevation view it belongs to relative to the marker (the view’s crop box transform is not honoured when set), and nothing else.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The document the marker is in.

  • marker (Autodesk.Revit.DB.ElevationMarker) – The elevation marker.

Returns:

The element ids of the pointers.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Views.elevation.get_pointer_of_view(pointers, view_id)

The pointer of a view among a marker’s pointers: a pointer is made just before its view, so it is the one with the largest id below the view’s.

Parameters:
  • pointers (list of Autodesk.Revit.DB.ElementId) – The marker’s pointers (get_pointers_of_marker).

  • view_id (Autodesk.Revit.DB.ElementId) – The id of the elevation view.

Returns:

The pointer’s id, None if there is none.

Return type:

Autodesk.Revit.DB.ElementId or None

duHast.Revit.Views.elevation.get_marker_centre_from_pointers(doc, marker)

The centre of an elevation marker’s circle, from the pointers of its views.

Each view on a marker has a pointer (a dependent element of the Viewers category, shown as “Views” in Revit, created just before the view, so the one with the largest id below the view’s) that sits along the view’s direction from the circle. The pointer’s bounding box in a plan view therefore has its centre on the line through the circle along the view’s direction, and the circle is where those lines cross: the least squares point over every view. Two opposite views alone fix the point as the middle of their pointers. One view cannot say how far along its line the circle is, so a marker with a single view answers None.

Measured on a marker with four views: the four pointers’ lines crossed at the circle’s centre, where the elevation lines’ own middles were 280 mm away (a line can be cropped off-centre).

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The document the marker is in.

  • marker (Autodesk.Revit.DB.ElevationMarker) – The elevation marker.

Returns:

The centre in feet, None if it cannot be worked out.

Return type:

Autodesk.Revit.DB.XYZ or None

duHast.Revit.Views.elevation.get_elevation_footprint(view)

Get the elevation line and how far the view looks, in model coordinates.

The crop box of an elevation is in the view’s own frame (x to the right, y up, z towards the viewer) and its transform takes it to the model. The elevation line is the crop box’s width on the plane through the view origin (z = 0); the view looks back from it along minus z, so the crop box’s minimum z is how far it sees.

Parameters:

view (Autodesk.Revit.DB.ViewSection) – The elevation view.

Returns:

(line start, line end, depth) as XYZ in feet and a length in feet, or None when the view has no crop box.

Return type:

(Autodesk.Revit.DB.XYZ, Autodesk.Revit.DB.XYZ, float) or None

duHast.Revit.Views.elevation.get_far_clip(view)

Get the far clip settings of an elevation view.

Parameters:

view (Autodesk.Revit.DB.ViewSection) – The elevation view.

Returns:

(mode, offset in mm). Mode is 0 for no clip, 1 for clip with line, 2 for clip without line (Revit’s own values); either is None when the parameter is missing.

Return type:

(int or None, float or None)

duHast.Revit.Views.elevation_marker module

Helper functions to make an elevation marker at a place and turn, create the views on it and set what they look at.

duHast.Revit.Views.elevation_marker.create_elevation_marker_without_transaction_wrapper(doc, view_type, location, scale, rotation=0.0)

Creates an elevation marker and turns it about its own point.

A marker holds up to four elevation views, one per index; turning the marker turns all of them, which is how an index is made to face a chosen wall.

Changing the model: this needs to run inside a transaction.

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

  • view_type (Autodesk.Revit.DB.ViewFamilyType) – The elevation view family type.

  • location (Autodesk.Revit.DB.XYZ) – Where the marker goes (z is the level it belongs to).

  • scale (int) – The scale of the views on the marker.

  • rotation (float, optional) – Counter clockwise turn about the marker’s point in radians, defaults to 0.0.

Returns:

Result class instance. .result holds the marker when it was created.

Return type:

Result

duHast.Revit.Views.elevation_marker.rotate_elevation_marker_without_transaction_wrapper(doc, marker, location, rotation)

Turns an elevation marker, and the views on it, about the marker’s own point.

Which way index 0 of a new marker looks is Revit’s to say, so a caller which needs a view to look a certain way creates the views first, reads where one looks (ViewSection.ViewDirection) and turns the marker by the difference.

Changing the model: this needs to run inside a transaction.

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

  • marker (Autodesk.Revit.DB.ElevationMarker) – The elevation marker.

  • location (Autodesk.Revit.DB.XYZ) – The marker’s point, in feet.

  • rotation (float) – Counter clockwise turn in radians.

Returns:

Result class instance.

Return type:

Result

duHast.Revit.Views.elevation_marker.create_elevation_on_marker_without_transaction_wrapper(doc, marker, view_plan, index, name=None, phase_id=None)

Creates the elevation view at one index of a marker.

Changing the model: this needs to run inside a transaction.

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

  • marker (Autodesk.Revit.DB.ElevationMarker) – The elevation marker.

  • view_plan (Autodesk.Revit.DB.ViewPlan) – The plan view the marker is in.

  • index (int) – The index on the marker, 0 to 3.

  • name (str, optional) – The name of the new view, defaults to None (Revit’s own).

  • phase_id (Autodesk.Revit.DB.ElementId, optional) – The phase of the new view, defaults to None (Revit’s own).

Returns:

Result class instance. .result holds the view when it was created.

Return type:

Result

duHast.Revit.Views.elevation_marker.get_rotation_to_face(look_x, look_y, index_zero_looks=(0.0, 1.0))

The turn, in radians counter clockwise, that makes index 0 of an unturned marker look along (look_x, look_y).

A new marker’s index 0 looks along +y in plan (indices 1 to 3 follow at quarter turns); this is the assumption to check when a marker comes out facing the wrong way, and the only place it is made.

Parameters:
  • look_x (float) – x of the direction to look along in plan.

  • look_y (float) – y of the direction to look along in plan.

  • index_zero_looks (tuple, optional) – The direction index 0 looks along on an unturned marker, defaults to (0.0, 1.0).

Returns:

The turn in radians, in (-pi, pi].

Return type:

float

duHast.Revit.Views.elevation_marker.set_elevation_extent_without_transaction_wrapper(view, line_start, line_end, depth, height=None, bottom=None)

Sets how wide and how far an elevation view looks.

The width is the crop box’s extent along the view’s right direction, taken from where the line’s two ends fall on it; the depth is the far clip, made active, at that offset from the view plane; the height, when given, is the crop box’s extent upwards from where its bottom already is.

Changing the model: this needs to run inside a transaction.

Parameters:
  • view (Autodesk.Revit.DB.ViewSection) – The elevation view.

  • line_start (Autodesk.Revit.DB.XYZ) – One end of the elevation line in the model, in feet.

  • line_end (Autodesk.Revit.DB.XYZ) – The other end, in feet.

  • depth (float or None) – How far the view looks from its plane, in feet; None or 0 leaves the far clip as it is.

  • height (float or None) – How tall the crop box is, in feet, measured up from its current bottom; None or 0 leaves the top as it is.

  • bottom (float or None) – Where the bottom of the crop box is, as a height in the model in feet (not above the level: absolute); None leaves the bottom as it is. With a height the top is bottom + height.

Returns:

Result class instance.

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.filters.create_filter(doc, filter_name, categories, element_filter, transaction_manager=<function in_transaction>)

Creates a view filter in Autodesk Revit.

Args:

doc (Autodesk.Revit.DB.Document): The document object representing the Revit model. filter_name (str): The name of the filter to be created. categories (list of Autodesk.Revit.DB.BuiltInCategory): The list of categories to be included in the view filter. (.net list!) element_filter (Autodesk.Revit.DB.ElementFilter): The element filter defining the categories for the view filter.

Returns:

duHast.Utilities.Objects.result.Result: The result object containing the outcome of creating the filter. The result attribute of the result object contains the created filter object if successful, or None if not. The messages attribute of the result object contains any additional messages related to the creation of the filter.

duHast.Revit.Views.filters.update_filter(doc, filter_name, categories, element_filter, transaction_manager=<function in_transaction>)

Updates an existing view filter in Autodesk Revit.

Args:

doc (Autodesk.Revit.DB.Document): The document object representing the Revit model. filter_name (str): The name of the filter to be created. categories (list of Autodesk.Revit.DB.BuiltInCategory): The list of categories to be included in the view filter. (.net list!) element_filter (Autodesk.Revit.DB.ElementFilter): The element filter defining the categories for the view filter.

Returns:

duHast.Utilities.Objects.result.Result: The result object containing the outcome of creating the filter. The result attribute of the result object contains the created filter object if successful, or None if not. The messages attribute of the result object contains any additional messages related to the creation 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_all_schedules_placed_on_sheets(doc, filter_revision_schedules=True)

Gets all schedules with an instance placed on a sheet. Optionally filter out revision schedules.

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

  • filter_revision_schedules (bool) – If true, titleblock revision schedules will be filtered out. Default is True.

Returns:

list of schedules with 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.get_schedules(doc)

Get all schedules in the current document excluding title block revision schedules.

Parameters:

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

Returns:

List of schedules in the current document.

Return type:

list[Autodesk.Revit.DB.ViewSchedule]

duHast.Revit.Views.schedules.get_schedule_by_name(doc, name)

Get a schedule by its name. Schedule templates and title block revision schedules are not considered.

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

  • name (str) – The schedule name.

Returns:

The schedule, None if there is none of that name.

Return type:

Autodesk.Revit.DB.ViewSchedule or None

duHast.Revit.Views.schedules.get_schedules_by_built_in_category(doc, built_in_category)

Get all schedules in the current document by built-in category.

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

  • built_in_category (Autodesk.Revit.DB.BuiltInCategory) – Built-in category to filter schedules by.

Returns:

List of schedules in the current document filtered by built-in category.

Return type:

list[Autodesk.Revit.DB.ViewSchedule]

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

Get all multi-category schedules in the current document.

Parameters:

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

Returns:

List of multi-category schedules in the current document.

Return type:

list[Autodesk.Revit.DB.ViewSchedule]

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

Get all schedules that are placed on sheets in the current document.

Parameters:

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

Returns:

List of schedules that are placed on sheets.

Return type:

list[Autodesk.Revit.DB.ViewSchedule]

duHast.Revit.Views.schedules.filter_split_schedules(schedules)

Returns only schedules which are split on sheet

Parameters:

schedules – a list of view schedule instances

Returns:

A list of schedules which are split on sheet or an empty list if none are split

duHast.Revit.Views.schedules_create module

Helper functions to make a schedule for one room from a base schedule and place it on a sheet.

duHast.Revit.Views.schedules_create.duplicate_schedule_without_transaction_wrapper(doc, schedule, new_name)

Duplicates a schedule (without its sheet placement) and names the copy.

Changing the model: this needs to run inside a transaction.

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

  • schedule (Autodesk.Revit.DB.ViewSchedule) – The schedule to duplicate.

  • new_name (str) – The name of the copy.

Returns:

Result class instance. .result holds the new schedule when it was created.

Return type:

Result

duHast.Revit.Views.schedules_create.set_first_filter_value_without_transaction_wrapper(schedule, value)

Sets the value of a schedule’s FIRST filter, keeping its field and its comparison. A base schedule for rooms has the room number as its first filter, so this limits the copy to one room.

Changing the model: this needs to run inside a transaction.

Parameters:
  • schedule (Autodesk.Revit.DB.ViewSchedule) – The schedule to change.

  • value (str) – The new filter value.

Returns:

Result class instance.

Return type:

Result

duHast.Revit.Views.schedules_create.place_schedule_on_sheet_without_transaction_wrapper(doc, sheet, schedule, point)

Places a schedule on a sheet.

Changing the model: this needs to run inside a transaction.

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

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

  • schedule (Autodesk.Revit.DB.ViewSchedule) – The schedule to place.

  • point (Autodesk.Revit.DB.XYZ) – Where the upper left corner of the schedule goes on the sheet, in feet.

Returns:

Result class instance. .result holds the schedule sheet instance when it was created.

Return type:

Result

duHast.Revit.Views.schedules_element_filters module

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

duHast.Revit.Views.schedules_element_filters.get_schedule_filters(schedule)
duHast.Revit.Views.schedules_element_filters.get_schedule_filters_by_field_name(schedule, field_name)

Gets the filters of a schedule by the field name.

Parameters:
  • schedule (Autodesk.Revit.DB.ViewSchedule) – Revit schedule view.

  • field_name (str) – Name of the field to get the filters for.

Returns:

List of filters that are applied to the schedule for the specified field name. If no filters are found, an empty list is returned.

Return type:

list of Autodesk.Revit.DB.ScheduleFilter

duHast.Revit.Views.schedules_element_filters.get_schedule_filters_and_index_by_field_name(schedule, field_name)

Gets the filters of a schedule by the field name.

Parameters:
  • schedule (Autodesk.Revit.DB.ViewSchedule) – Revit schedule view.

  • field_name (str) – Name of the field to get the filters for.

Returns:

List of tuples in format(filter, index) that are applied to the schedule for the specified field name. If no filters are found, an empty list is returned.

Return type:

list of Autodesk.Revit.DB.ScheduleFilter

duHast.Revit.Views.schedules_export module

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

duHast.Revit.Views.schedules_export.export_schedule_to_file(schedule, file_path, field_delimiter=', ', export_title=False, export_column_headers=Autodesk.Revit.DB.ExportColumnHeaders.None, export_text_qualifier=Autodesk.Revit.DB.ExportTextQualifier.DoubleQuote)

Exports a Revit schedule to a file.

Parameters:
  • schedule (Autodesk.Revit.DB.ViewSchedule) – The schedule to export.

  • file_path (str) – The file path to export the schedule to.

  • field_delimiter (str, optional) – The delimiter to use between fields in the exported file.

  • export_title (bool, optional) – Whether to include the schedule title in the exported file.

  • export_column_headers (Autodesk.Revit.DB.ExportColumnHeaders, optional) – The type of column headers to include in the exported file.

  • export_text_qualifier (Autodesk.Revit.DB.ExportTextQualifier, optional) – The text qualifier to use in the exported file.

Returns:

Result object containing success status and messages.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.schedules_fields module

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

duHast.Revit.Views.schedules_fields.schedule_contains_field_by_parameter_id(schedule, parameter_id, ignore_hidden_field=False)

Checks if the given schedule contains a specific field identified by the parameter Id.

Parameters:
  • schedule (Autodesk.Revit.DB.ViewSchedule) – The schedule to check.

  • parameter_id (Autodesk.Revit.DB.ElementId) – The parameter Id of the field to check for.

  • ignore_hidden_field (bool, optional) – If True, a hidden field returns false.

Returns:

True if the schedule contains the sheet number field, False otherwise.

Return type:

bool

duHast.Revit.Views.schedules_fields.schedule_contains_sheet_number_field(schedule, ignore_hidden_field=False)

Checks if the given schedule contains the sheet number field.

Parameters:
  • schedule (Autodesk.Revit.DB.ViewSchedule) – The schedule to check.

  • ignore_hidden_field (bool, optional) – If True, a hidden sheet number field returns false.

Returns:

True if the schedule contains the sheet number field, False otherwise.

Return type:

bool

duHast.Revit.Views.schedules_fields.get_field_names_from_schedule(schedule)

Get a list of all field names from a Revit schedule. :param schedule: The Revit schedule object from which to extract field names. :type schedule: Autodesk.Revit.DB.ViewSchedule

Returns:

A list of field names in the schedule.

Return type:

list of str

duHast.Revit.Views.schedules_fields.get_field_names_to_parameters(schedule)

Get a dictionary of field names to their corresponding parameters in a Revit schedule.

Parameters:

schedule (Autodesk.Revit.DB.ViewSchedule) – The Revit schedule object from which to extract field names and parameters.

Returns:

A dictionary where keys are field names and values are the corresponding parameter IDs.

duHast.Revit.Views.schedules_fields.get_field_column_index_from_schedule_by_parameter_id(schedule, parameter_id)

Returns the index of a field in a Revit schedule based on the parameter ID.

If the field is hidden or not found will return -1.

Takes into account if other fields are hidden or not, so the index is based on visible fields only.

Parameters:
  • schedule (Autodesk.Revit.DB.ViewSchedule) – The Revit schedule object from which to extract the field index.

  • parameter_id (Autodesk.Revit.DB.ElementId) – The parameter ID of the field to find.

Returns:

The index of the field in the schedule, or -1 if not found or hidden.

Return type:

int

duHast.Revit.Views.schedules_fields.get_field_from_schedule_by_field_name(schedule, field_name)

Returns the field matching the given name.

Parameters:
  • schedule (Autodesk.Revit.DB.ViewSchedule) – The Revit schedule object from which to extract the field index.

  • field_name (str) – The human readable field name

Returns:

The field or None if no match was found.

Return type:

Autodesk.Revit.DB.ScheduleField

duHast.Revit.Views.schedules_fields.get_field_values_from_schedule_by_parameter_id(schedule, parameter_id=None)

Get a list of all field values from a Revit schedule based on the parameter id.

Parameters:

schedule (Autodesk.Revit.DB.ViewSchedule) – The Revit schedule object from which to extract field values.

Returns:

A list of field values in the schedule.

Return type:

list of str

duHast.Revit.Views.schedules_fields.get_schedules_column_widths(schedules, field_names_of_interest=[])

Returns a list of lists with schedule id and column data for the specified field names of interest. If no field names of interest are provided, will return column data for all fields in the schedule.

Each row starts with the schedule id followed by tuples of field name and column width in inches for each field of interest.

Parameters:
  • schedules (list of Autodesk.Revit.DB.ViewSchedule) – A list of Revit schedule objects to extract column width data from.

  • field_names_of_interest (list of str, optional) – A list of field names to extract column width data for. If empty, will extract column width data for all fields in the schedule.

Returns:

A Result object containing a list of lists with schedule id and column data for the specified field names of interest, or an error message if the operation fails.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.schedules_modify module

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

duHast.Revit.Views.schedules_modify.adjust_column_width(doc, schedules, field_data, callback_progress=None)

Adjusts the column width of a specified field in a list of schedules.

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

  • schedules (list of Autodesk.Revit.DB.ViewSchedule) – A list of Revit schedule objects to adjust.

  • field_data (dict[int, dict[str, int]]) – A dictionary where the key is the schedule id and the values are another dictionary with the field name (key) and column width (value) to set.

  • callback_progress (function, optional) – An optional callback function to update the progress of the operation. The function should accept two parameters: the current progress (int) and the maximum progress (int).

Returns:

A Result object containing a list of schedules that were skipped because they did not contain the specified field.

Return type:

duHast.Utilities.Objects.result.Result

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.schedules_sheet_instances module

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

duHast.Revit.Views.schedules_sheet_instances.get_sheets_with_overlapping_schedules(doc, sheets, callback_progress=None)

Returns a list of sheets where schedules are overlapping the titleblock, along with the overlapping schedule instances and their required X-axis adjustments.

Args:

doc: The Revit document. sheets: A list of ViewSheet objects to check.

Returns:

list of tuples: [(sheet, {instance_id: delta_x}), …] where each tuple contains a sheet and a dictionary of overlapping schedule instance IDs and their required X-axis adjustments.

duHast.Revit.Views.schedules_sheet_instances.get_sheets_with_schedules_outside_titleblock(doc, sheets, callback_progress=None)

Checks all provided sheets for schedule instances extending outside the titleblock boundary.

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

  • sheets (list of Autodesk.Revit.DB.ViewSheet) – A list of ViewSheet objects to check.

Returns:

A list of tuples containing the sheet and a dictionary of schedule instance IDs and the edges they violate.

Return type:

list of (Autodesk.Revit.DB.ViewSheet, { instance_id_int: [edge_strings] })

duHast.Revit.Views.schedules_sheet_instances.get_sheets_with_schedules_overlapping_viewports(doc, sheets, callback_progress=None)

Checks all provided sheets for schedule instances overlapping any viewport.

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

  • sheets (list of Autodesk.Revit.DB.ViewSheet) – A list of ViewSheet objects to check.

Returns:

A list of tuples containing the sheet and a dictionary of overlapping schedule instance IDs and their required X movement.

Return type:

list of (Autodesk.Revit.DB.ViewSheet, { instance_id_int: delta_x_in_feet })

duHast.Revit.Views.schedules_sheet_instances_move module

This module contains a number of helper functions relating to moving of Revit sheet schedule instances.

duHast.Revit.Views.schedules_sheet_instances_move.move_schedule_instance_along_x(doc, segments_to_move, schedule_name)

Moves schedule segment along the X axis by a given distance.

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

  • segments_to_move ({ instance_id_int: delta_x_in_feet }) – A Dictionary containing as key the view schedule segment Id and the distance along the X it is to move in inches

Returns:

A Result object containing the move status and message for each segment moved.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.schedules_sheet_instances_move.resolve_overlaps(doc, schedule, schedule_name, max_iterations=10)

Check if schedule segments are overlapping and if so move them iteratively until no more overlaps are detected or max iterations is reached.

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

  • schedule (Autodesk.Revit.DB.ViewSchedule) – The Revit schedule object to check for overlaps.

  • schedule_name (str) – The name of the schedule being processed (used for logging).

  • max_iterations (int) – The maximum number of iterations to attempt to resolve overlaps (default is 10).

Returns:

A Result object containing a list of schedules that were skipped because they did not contain the specified field.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.schedules_sheet_instances_move.move_schedule_sheet_instances_in_x_until_no_overlap(doc, schedules, callback_progress=None)

Finds any split schedule in the model and moves segments 1 to n (skips 0) by a given distance (the overlap) to the right.

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

  • schedules (list of Autodesk.Revit.DB.ViewSchedule) – A list of Revit schedule objects to check for overlaps and move if necessary.

  • callback_progress (function, optional) – An optional callback function to update the progress of the operation. The function should accept two parameters: the current progress (int) and the maximum progress (int).

Returns:

A Result object containing the move status and message for each schedule processed.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.schedules_sheet_instances_overlap module

This module contains a number of helper functions relating to moving of Revit sheet schedule instances overlapping.

duHast.Revit.Views.schedules_sheet_instances_overlap.check_schedule_sheet_instances_are_overlapping(doc, schedule, sheet_id=None)

Checks if any segments of a split schedule overlap on their respective sheets.

Returns a dictionary mapping segment instance IDs (int) to the distance in feet they need to move in the X direction to resolve the overlap. If the schedule is not split or no overlaps are found, an empty dictionary is returned.

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

  • schedule (Autodesk.Revit.DB.ViewSchedule) – The Revit schedule object from which to extract the field index.

Returns:

a dictionary where key is the schedule sheet instance Id as integer and the distance it has to move to avoid overlap with the previous segment.

Return type:

{ instance_id_int: delta_x_in_feet }

duHast.Revit.Views.schedules_sheet_instances_overlap.check_schedules_overlap_titleblock(doc, sheet)

Checks if any schedule sheet instances on a given sheet overlap with the titleblock (inside the title block)

Returns a dictionary mapping schedule sheet instance IDs (int) to the distance in feet they need to move in the X direction to clear the titleblock.

Args:

doc: The Revit document. sheet: The ViewSheet to check.

Returns:

dict: { instance_id (int): delta_x (float) } for each overlapping schedule instance.

duHast.Revit.Views.schedules_sheet_instances_overlap.check_schedules_outside_titleblock(doc, sheet)

Checks if any schedule sheet instances on a given sheet extend outside the titleblock boundary.

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

  • sheet (Autodesk.Revit.DB.ViewSheet) – The ViewSheet to check.

Returns:

a dictionary where key is the schedule sheet instance Id as integer and a list of edges it is outside of.

Return type:

{ instance_id_int: [edge_strings] }

duHast.Revit.Views.schedules_sheet_instances_overlap.check_schedules_overlap_viewports(doc, sheet)

Checks if any schedule sheet instances on a given sheet overlap with any viewports.

Returns a dictionary mapping schedule sheet instance IDs (int) to the distance in feet they need to move in the X direction to clear the overlapping viewport.

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

  • sheet (Autodesk.Revit.DB.ViewSheet) – The ViewSheet to check.

Returns:

a dictionary where key is the schedule sheet instance Id as integer and the distance it has to move to avoid overlap with a viewport.

Return type:

{ instance_id_int: delta_x_in_feet }

duHast.Revit.Views.schedules_sheets_export module

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.get_titleblock_bounding_box(doc, sheet)

Returns the bounding box of the titleblock on a sheet, or None if not found.

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

Returns the width and height of a sheet’s title block in millimetres, from its bounding box on the sheet.

Args:

doc (Autodesk.Revit.DB.Document): Current Revit model document. sheet (Autodesk.Revit.DB.ViewSheet): The sheet.

Returns:

tuple (float, float) or None: width, height in mm as measured (not snapped to a paper size), or None when the sheet has no title block or the box is empty.

duHast.Revit.Views.sheets.get_sheets_from_schedule_instances(doc, schedules)

Returns a list of sheets that contain schedule sheet instances of the provided schedules.

Args:

doc (Autodesk.Revit.DB.Document): Current Revit model document. schedules (list of Autodesk.Revit.DB.ViewSchedule): List of schedules to check for instances on sheets.

Returns:

list of Autodesk.Revit.DB.ViewSheet: List of sheets that contain schedule sheet instances of the provided schedules.

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.view_3d_create module

View crop utilities.

duHast.Revit.Views.view_3d_create.create_view_3d_around_box_without_transaction_wrapper(doc, view_type, view_name, forward, up, box_min, box_max, phase=None, rotation=0.0)

Creates an isometric 3D view that looks along a direction at a box, and cuts the model to that box (the section box). The view is cropped to the section box as the camera sees it (Crop View on, fitted tightly).

The camera is put back along the direction far enough to see the whole box, so the box is what the view shows whatever height the model sits at: the pitch comes from the direction.

Must be called inside a transaction.

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

  • view_type (Autodesk.Revit.DB.ViewFamilyType) – The 3D view family type.

  • view_name (str) – The name of the new view.

  • forward (tuple of float) – The direction the view looks along (x, y, z); any length.

  • up (tuple of float) – The view’s up direction (x, y, z); any length.

  • box_min (Autodesk.Revit.DB.XYZ) – The corner of the box with the smallest coordinates, in feet.

  • box_max (Autodesk.Revit.DB.XYZ) – The opposite corner, in feet.

  • phase (Autodesk.Revit.DB.Phase, optional) – The phase of the view, defaults to None (Revit’s default).

  • rotation (float, optional) – A counter clockwise turn of the section box about its own centre, in radians, defaults to 0.0. box_min and box_max are then the corners of the box before the turn, so a room at an angle is cut by a box square to its walls (measured in Revit 2026: a 3D view keeps a turned section box Transform, unlike a plan view’s crop). The direction is not turned with it: pass the forward and up the camera should have.

Returns:

Result with the new view in its result list.

Return type:

Result

duHast.Revit.Views.view_sheet_sets module

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

duHast.Revit.Views.view_sheet_sets.get_view_sheet_sets(doc)

Get all view sets in the Revit document. :param doc: The Revit document to search for view sets. :type doc: Autodesk.Revit.DB.Document

Returns:

A filtered element collector containing all view sets.

Return type:

FilteredElementCollector

duHast.Revit.Views.view_sheet_sets.get_sheet_and_view_ids_from_view_sheet_set(view_sheet_set)

Extracts sheet and view IDs from a given view set. :param view_sheet_set: The view set from which to extract sheet and view IDs. :type view_sheet_set: Autodesk.Revit.DB.ViewSheetSet

Returns:

A tuple containing two lists: sheet IDs and view IDs.

Return type:

tuple

duHast.Revit.Views.view_sheet_sets.get_sheets_and_views_from_view_sheet_set(view_sheet_set)

Extracts sheets and views from a given view set. :param view_sheet_set: The view set from which to extract sheet and view IDs. :type view_sheet_set: Autodesk.Revit.DB.ViewSheetSet

Returns:

A tuple containing two lists: sheet IDs and view IDs.

Return type:

tuple

duHast.Revit.Views.view_sheet_sets.get_sheets_from_view_sheet_set(view_sheet_set)

Extracts only the sheets from a given view set.

Parameters:

view_sheet_set (Autodesk.Revit.DB.ViewSheetSet) – The view set from which to extract sheet objects.

Returns:

A list of sheet objects.

Return type:

list

duHast.Revit.Views.view_sheet_sets.get_views_from_view_sheet_set(view_sheet_set)

Extracts only the views from a given view set.

Parameters:

view_sheet_set (Autodesk.Revit.DB.ViewSheetSet) – The view set from which to extract sheet objects.

Returns:

A list of view objects.

Return type:

list

duHast.Revit.Views.view_sheet_sets.get_sheet_ids_from_view_sheet_set(view_sheet_set)

Extracts only the sheet ids from a given view set.

Parameters:

view_sheet_set (Autodesk.Revit.DB.ViewSheetSet) – The view set from which to extract sheet objects.

Returns:

A list of Element Id objects.

Return type:

list

duHast.Revit.Views.view_sheet_sets.get_view_ids_from_view_sheet_set(view_sheet_set)

Extracts only the view ids from a given view set.

Parameters:

view_sheet_set (Autodesk.Revit.DB.ViewSheetSet) – The view set from which to extract sheet objects.

Returns:

A list of Element Id objects.

Return type:

list

duHast.Revit.Views.view_sheet_sets.get_view_sheet_set_by_name(doc, view_sheet_set_name)

Retrieves a view set by its name from the Revit document.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The Revit document to search for the view set.

  • view_sheet_set_name (str) – The name of the view set to retrieve.

Returns:

The ViewSheetSet object if found, otherwise None.

Return type:

Autodesk.Revit.DB.ViewSheetSet or None

duHast.Revit.Views.view_sheet_sets.get_current_view_sheet_settings_element(doc)

Retrieves the current ViewSheetSetting element from the Revit document.

Parameters:

doc (Autodesk.Revit.DB.Document) – The Revit document from which to retrieve the ViewSheetSetting.

Returns:

The ViewSheetSetting element if found, otherwise None.

Return type:

Autodesk.Revit.DB.ViewSheetSetting or None

duHast.Revit.Views.view_sheet_sets.update_view_sheet_set(doc, view_sheet_set, view_sheet_setting, sheets, views, clear_existing=True, transaction_manager=<function in_transaction>, save_after_update=True)

Updates the view set with the given sheets and views.

If either views or sheets list is empty, the function will clear the existing sheets or views if clear_existing is set to true. Otherwise it will maintain those types of views unchanged (clear_existing=False).

Parameters:
  • view_sheet_set (Autodesk.Revit.DB.ViewSheetSet) – The view set to update.

  • sheets (list) – The list of sheets to add to the view set.

  • views (list) – The list of views to add to the view set.

  • clear_existing (bool) – Whether to clear existing sheets or views before adding new ones.

  • transaction_manager (function) – The transaction manager to use for the operation. If none is provided, the action will be executed assuming there is an open transaction already set up by the caller.

Returns:

A Result object indicating the success or failure of the operation. Messages are quite detailed to allow for debugging and understanding what is happening in the function.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.view_sheet_sets.update_view_sheet_set_by_name(doc, view_sheet_set_name, sheets, views, clear_existing=True, transaction_manager=<function in_transaction>)

Updates a view set with the given name, sheets, and views in the Revit document.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The Revit document in which to update the view set.

  • view_sheet_set_name (str) – The name of the view set to update.

  • sheets (list) – A list of sheets to include in the view set.

  • views (list) – A list of views to include in the view set.

  • clear_existing (bool) – Whether to clear existing sheets or views before adding new ones.

  • transaction_manager (function) – The transaction manager to use for the operation. If none is provided, the action will be executed assuming there is an open transaction already set up by the caller.

Returns:

A Result object indicating the success or failure of the operation. Messages are quite detailed to allow for debugging and understanding what is happening in the function. if the view set does not exist, the result will contain the name of the view set that was not found. ( that is the only time the result will contain as single string)

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.view_sheet_sets.create_new_view_sheet_set(doc, view_sheet_set_name, sheets, views, transaction_manager=<function in_transaction>)

Creates a new view set with the given name, sheets, and views in the Revit document.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The Revit document in which to create the view set.

  • view_sheet_set_name (str) – The name of the new view set to create.

  • sheets (list) – A list of sheets to include in the new view set.

  • views (list) – A list of views to include in the new view set.

  • transaction_manager (function) – The transaction manager to use for the operation. If none is provided, the action will be executed assuming there is an open transaction already set up by the caller.

Returns:

A Result object indicating the success or failure of the operation. Messages are quite detailed to allow for debugging and understanding what is happening in the function.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.view_sheet_sets.delete_view_sheet_set_by_name(doc, view_sheet_set_name, transaction_manager=<function in_transaction>)

Deletes a view sheet set by its name from the Revit document.

Parameters:
  • doc (Autodesk.Revit.DB.Document) – The Revit document from which to delete the view sheet set.

  • view_sheet_set_name (str) – The name of the view sheet set to delete.

  • transaction_manager (function) – The transaction manager to use for the operation. If none is provided, the action will be executed assuming there is an open transaction already set up by the caller.

Returns:

A Result object indicating the success or failure of the operation. Messages are quite detailed to allow for debugging and understanding what is happening in the function.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.viewports_create module

Helper functions to place views on sheets as viewports.

duHast.Revit.Views.viewports_create.create_viewport_without_transaction_wrapper(doc, sheet, view, centre, viewport_type_id=None, label_offset=None, label_line_length=None)

Places a view on a sheet.

Changing the model: this needs to run inside a transaction.

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

  • sheet (Autodesk.Revit.DB.ViewSheet) – The sheet to place the view on.

  • view (Autodesk.Revit.DB.View) – The view to place.

  • centre (Autodesk.Revit.DB.XYZ) – Where the centre of the viewport box goes on the sheet, in feet (z is ignored). The box excludes the view title, as Viewport.GetBoxCenter does.

  • viewport_type_id (Autodesk.Revit.DB.ElementId, optional) – The viewport type to apply, defaults to None (the default type).

  • label_offset (Autodesk.Revit.DB.XYZ, optional) – Where the view title goes: from the bottom left corner of the viewport box to the left end of the title line, in feet (z is ignored); defaults to None (Revit’s default place).

  • label_line_length (float, optional) – The length of the title line in feet, defaults to None (Revit’s default).

Returns:

Result class instance. .result holds the viewport when it was created.

Return type:

Result

duHast.Revit.Views.viewports_create.get_viewport_outline_size(viewport)

Returns the size of a viewport on its sheet.

Parameters:

viewport (Autodesk.Revit.DB.Viewport) – The viewport.

Returns:

Width and height in feet.

Return type:

tuple (float, float)

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_family_types(doc, view_family)

Returns the view family types of one view family (floor plan, elevation, section…).

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

  • view_family (Autodesk.Revit.DB.ViewFamily) – The view family.

Returns:

The matching view family types.

Return type:

list[Autodesk.Revit.DB.ViewFamilyType]

duHast.Revit.Views.views.get_view_family_type_by_name(doc, view_family, name)

Returns the view family type of a view family with the given name.

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

  • view_family (Autodesk.Revit.DB.ViewFamily) – The view family.

  • name (str) – The type name.

Returns:

The view family type, None if there is none of that name.

Return type:

Autodesk.Revit.DB.ViewFamilyType or None

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_in_model_not_template(doc)

Gets all views in a model which are not templates and not driven by a template.

Parameters:

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

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_crop.set_view_crop_around_point_without_transaction_wrapper(view, centre, width, height)

Activates the crop of a view and sets it to a rectangle of the given size centred on a point.

The rectangle is built in the crop box’s own coordinate system and keeps the crop box’s Z range. The crop region is made active and its visibility is switched off.

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

  • centre (Autodesk.Revit.DB.XYZ) – The point to centre the crop on, in model coordinates (feet).

  • width (float) – The crop width in the view’s horizontal direction (feet).

  • height (float) – The crop height in the view’s vertical direction (feet).

Returns:

The result of the operation.

Return type:

duHast.Utilities.Objects.result.Result

duHast.Revit.Views.views_crop.get_crop_box_element_candidates(doc, view)

The elements that may be a plan view’s crop box element, the most likely first.

View.CropBox is only a BoundingBoxXYZ; the element that draws the crop region is not reachable through the API by a property. Revit creates it with the view, so its id sits next to the view’s: the view’s id + 2 (learnrevitapi, and measured in Revit 2026). It carries the view’s name, and it has no category: a lookup by the Viewers category (a collector, GetDependentElements, or comparing what the view shows with the crop hidden and shown) finds nothing. So the candidates are the elements within CROP_ELEMENT_SEARCH ids of the view whose name is the view’s, + 2 first, then by distance. Only turning one tells which it is, which is what rotate_view_crop_without_transaction_wrapper does.

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

  • view (Autodesk.Revit.DB.View) – The plan view.

Returns:

The candidates’ ids, most likely first; empty when there is none.

Return type:

list of Autodesk.Revit.DB.ElementId

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

Takes away what stops a plan view’s crop from being turned freely: a scope box, and an orientation of True North.

A scope box decides the crop of the view it is assigned to, and a view oriented to True North turns with the project’s angle to it rather than with its crop. Both are set back: the scope box to none and the orientation to Project North. A view whose orientation is read only (a view template controls it) is reported, not changed.

Changing the model: this needs to run inside a transaction.

Parameters:

view (Autodesk.Revit.DB.View) – The plan view.

Returns:

Result class instance.

Return type:

Result

duHast.Revit.Views.views_crop.rotate_view_crop_without_transaction_wrapper(doc, view, centre, rotation)

Turns a plan view by turning its crop box element about a point, so a room at an angle sits square in the view and on the sheet.

A plan view ignores a turned Transform on its CropBox (only Min and Max are honoured, measured in Revit 2026), so the view is turned by rotating the element that draws its crop. That element is found by its id (get_crop_box_element_candidates); each candidate is rotated inside a sub-transaction, kept if the view’s right direction turned by the rotation asked for, and undone otherwise. The crop is made active and visible while it is turned, and its visibility put back afterwards. A scope box and True North are cleared first (clear_view_crop_blockers_without_transaction_wrapper).

After the turn the crop’s own frame is the turned one: fit it with fit_view_crop_to_points_without_transaction_wrapper, which works in that frame.

Changing the model: this needs to run inside a transaction.

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

  • view (Autodesk.Revit.DB.ViewPlan) – The plan view.

  • centre (Autodesk.Revit.DB.XYZ) – The point to turn about, in model coordinates (feet); its z is not used.

  • rotation (float) – Counter clockwise turn in radians. The view’s right direction turns by this much, which squares a room whose walls run at this angle.

Returns:

Result class instance. .result holds the id of the crop box element that turned the view.

Return type:

Result

duHast.Revit.Views.views_crop.fit_view_crop_to_points_without_transaction_wrapper(view, points, left=0.0, right=0.0, bottom=0.0, top=0.0)

Fits a view’s crop round points, in the crop’s own frame, with an offset on each side.

Working in the crop’s own frame (CropBox.Transform) is what makes this right for a turned view: the sides are the view’s left, right, bottom and top, which on a view turned by rotate_view_crop_without_transaction_wrapper are square to the room, so a template’s offsets from its room apply unchanged. Measured in Revit 2026: refitting a view turned 30 and -45 degrees this way keeps the turn and gives the room’s own rectangle exactly. The crop box’s z range is kept.

Changing the model: this needs to run inside a transaction.

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

  • points (list of Autodesk.Revit.DB.XYZ) – The points to fit round, in model coordinates (feet), for example a room’s boundary.

  • left (float, optional) – The offset outside the points on the view’s left, in feet, defaults to 0.0.

  • right (float, optional) – The offset on the view’s right, in feet, defaults to 0.0.

  • bottom (float, optional) – The offset at the view’s bottom, in feet, defaults to 0.0.

  • top (float, optional) – The offset at the view’s top, in feet, defaults to 0.0.

Returns:

Result class instance.

Return type:

Result

duHast.Revit.Views.views_names module

Helper functions to check view names. Revit refuses to name a view the same as another view.

duHast.Revit.Views.views_names.get_view_names(doc)

Returns the names of all views in the model (not view templates, not schedules’ internal views).

Parameters:

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

Returns:

The set of view names, lower case.

Return type:

set of str

duHast.Revit.Views.views_names.is_view_name_in_use(doc, name, view_names=None)

Checks whether a view with this name exists (case and surrounding white space are ignored).

This is the check to run before creating views, to refuse work that would collide, rather than letting Revit refuse the name half way through.

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

  • name (str) – The name to check.

  • view_names (set of str, optional) – The names from get_view_names, when the caller checks many names, defaults to None (they are read).

Returns:

True if a view has this name.

Return type:

bool

duHast.Revit.Views.views_names.get_views_in_name_collision(doc, names)

Returns those of the names which are already the name of a view.

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

  • names (list of str) – The names to check.

Returns:

The names in use, as given.

Return type:

list of str

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: RevitCategoryOverride}

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