Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.Levels package

Subpackages

Submodules

duHast.Revit.Levels.levels module

Revit levels helper functions.

duHast.Revit.Levels.levels.get_levels_in_model(doc)

Get all levels in model

Parameters:

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

Returns:

A collector with all levels in model.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Levels.levels.get_levels_in_view(doc, view)

Get all levels in a view

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

  • view (Autodesk.Revit.DB.View) – The view to get grids from.

Returns:

A collector with all grids in view.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Levels.levels.get_levels_list_ascending(doc)

Gets a filtered element collector of all levels in the model ascending by project elevation.

Filters by category.

Parameters:

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

Returns:

A filtered element collector of levels

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Levels.levels.get_levels_list_descending(doc)

Gets a filtered element collector of all levels in the model descending by project elevation.

Filters by category.

Parameters:

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

Returns:

A filtered element collector of levels

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Levels.levels.get_level_elevation_by_name(doc, level_name)
duHast.Revit.Levels.levels.get_all_level_heads_by_category(doc)

Gets a filtered element collector of all level head types in the model.

Filters by category.

Parameters:

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

Returns:

A filtered element collector of level heads

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Levels.levels.get_all_level_types_by_category(doc)

Gets a filtered element collector of all level types in the model.

Filters by category.

Parameters:

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

Returns:

A filtered element collector of level types.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Levels.levels.get_all_level_type_ids_by_category(doc)

Gets a list of all level type ids in the model.

Parameters:

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

Returns:

A list of all level type ids.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Levels.levels.get_all_level_head_family_type_ids(doc)

Gets ids of all level head family symbols (types) in the model.

Parameters:

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

Returns:

A list of symbol ids.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Levels.levels.get_nearest_level_absolute(z, levels, ignore_level_names)

Returns the nearest level matching the Z value and the offset adjustment from the level (in metric!!) in a tuple.

Note: Will return None if the placement level could not be determined. Nearest level is the level with the shortest absolute distance to the Z value and which is not in the ignore_level_names list. If the Z value is below the lowest level elevation in the model the lowest level will be returned. If the Z value is above the highest level elevation in the model the highest level will be returned.

Parameters:
  • z (float) – The Z coordinate (metric!)

  • levels (list) – List of levels in the model. (sorted ascending)

Returns:

Returns the level and the offset adjustment (in metric) from the source family instance level.

Return type:

tuple

duHast.Revit.Levels.levels.get_nearest_lowest_level(z, levels, ignore_level_names)

Returns the nearest lowest level below the Z value and the offset adjustment from the level (in metric) in a tuple.

Note: Will return None if the placement level could not be determined. Nearest level is the level below or at the Z value and which is not in the ignore_level_names list.

Parameters:
  • z (float) – The Z coordinate (metric!)

  • levels (list) – List of levels in the model. (needs to be sorted ascending)

Returns:

Returns the level and the offset adjustment (in metric) from the source family instance level.

Return type:

tuple

duHast.Revit.Levels.levels_appearance module

Revit levels appearance modifier functions.

Note: Any level appearance modification in a view will throw an exception if the level is not actually visible in the view.

duHast.Revit.Levels.levels_appearance.change_levels_2D(doc, levels, view)

Changes all levels in view to 2D

Note: Any level past in, which is not visible in the view, will throw an exception when attempting to set to 2D.

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

  • levels ([Autodesk.Revit.DB.Level]) – List of levels to be changed to 2D.

  • view (Autodesk.Revit.DB.View) – The view in which to change the levels

Returns:

Result class instance. - result.status. True if all levels where set to 2D, otherwise False. - result.message will contain the name(s) of the level(s) changed to 2D - result.result empty list On exception: - result.status (bool) will be False. - result.message will contain generic exception message including the level name. - result.result will be empty

Return type:

Result

duHast.Revit.Levels.levels_appearance.show_head_end(doc, level, view, end_identifier, show_head)

Toggles level head visibility on specified end for given level.

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

  • level (Autodesk.Revit.DB.Level) – The level of which a heads visibility is to be toggled.

  • view (Autodesk.Revit.DB.View) – The view in which a level heads visibility is to be toggled.

  • end_identifier – which end.

  • show_head (bool) – True head will switched on, False it will be switched off

Returns:

Result class instance. - result.status. True if all levels head(s) visibility was set successfully, otherwise False. - result.message will contain the name(s) of the level(s) where a head visibility was set. - result.result empty list On exception: - result.status (bool) will be False. - result.message will contain generic exception message including the level name. - result.result will be empty

Return type:

Result

duHast.Revit.Levels.levels_appearance.hide_both_heads(doc, levels, view)

Hides both heads of levels in the given view.

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

  • level (Autodesk.Revit.DB.Level) – The level of which a head’s visibility is to be toggled.

  • view (Autodesk.Revit.DB.View) – The view in which a level head’s visibility is to be toggled.

Returns:

Result class instance.

  • result.status (bool): True if all levels’ head(s) visibility was switched off successfully, otherwise False.

  • result.message (str): Contains the name(s) of the level(s) where a head visibility was set.

  • result.result (list): Empty list.

On exception:

  • result.status (bool) will be False.

  • result.message (str) will contain a generic exception message including the level name.

  • result.result (list) will be empty.

Return type:

Result

duHast.Revit.Levels.levels_appearance.show_head_zero_end(doc, levels, view)

Turns on level heads at zero end in specified view.

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

  • level ([Autodesk.Revit.DB.Level]) – The levels of which a heads visibility is to be toggled.

  • view (Autodesk.Revit.DB.View) – The view in which a level heads visibility is to be toggled.

Returns:

Result class instance.

  • result.status. True if all levels head(s) visibility at zero end was set to visible successfully, otherwise False.

  • result.message will contain the name(s) of the level(s) where a head visibility was set.

  • result.result empty list

On exception:

  • result.status (bool) will be False.

  • result.message will contain generic exception message including the level name.

  • result.result will be empty

Return type:

Result

duHast.Revit.Levels.levels_appearance.show_head_one_end(doc, levels, view)

Turns on level heads at One end in specified view.

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

  • level ([Autodesk.Revit.DB.Level]) – The levels of which a heads visibility is to be toggled.

  • view (Autodesk.Revit.DB.View) – The view in which a level heads visibility is to be toggled.

Returns:

Result class instance.

  • result.status. True if all levels head(s) visibility at one end was set to visible successfully, otherwise False.

  • result.message will contain the name(s) of the level(s) where a head visibility was set.

  • result.result empty list

On exception:

  • result.status (bool) will be False.

  • result.message will contain generic exception message including the level name.

  • result.result will be empty

Return type:

Result

duHast.Revit.Levels.levels_appearance.toggle_head_end(doc, level, view, end_identifier)

Toggles level head visibility on specified end for given level in given views.

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

  • level (Autodesk.Revit.DB.Level) – The level of which a heads visibility is to be toggled.

  • view (Autodesk.Revit.DB.DatumEnds) – The view in which a level heads visibility is to be toggled.

  • end_identifier – The end of the level to be modified.

Returns:

Result class instance.

  • result.status. True if all levels head(s) visibility was changed successfully, otherwise False.

  • result.message will contain the name(s) of the level(s) where a head visibility was changed.

  • result.result empty list

On exception:

  • result.status (bool) will be False.

  • result.message will contain generic exception message including the level name.

  • result.result will be empty

Return type:

Result

duHast.Revit.Levels.levels_appearance.toggle_head_one_end(doc, levels, view)

Toggles level head visibility on one end for given levels

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

  • levels ([Autodesk.Revit.DB.Level]) – The levels of which a heads visibility at one end is to be toggled.

  • view (Autodesk.Revit.DB.View) – The view in which a level heads visibility is to be toggled.

Returns:

Result class instance.

  • result.status. True if all levels head(s) visibility at one end was changed successfully, otherwise False.

  • result.message will contain the name(s) of the level(s) where a head visibility was changed.

  • result.result empty list

On exception:

  • result.status (bool) will be False.

  • result.message will contain generic exception message including the level name.

  • result.result will be empty

Return type:

Result

duHast.Revit.Levels.levels_appearance.toggle_head_zero_end(doc, levels, view)

Toggles level head visibility on zero end for given levels

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

  • levels ([Autodesk.Revit.DB.Level]) – The levels of which a head visibility at zero end is to be toggled.

  • view (Autodesk.Revit.DB.View) – The view in which a level heads visibility is to be toggled.

Returns:

Result class instance.

  • result.status. True if all level head(s) visibility at one end was changed successfully, otherwise False.

  • result.message will contain the name(s) of the level(s) where a head visibility was changed.

  • result.result empty list

On exception:

  • result.status (bool) will be False.

  • result.message will contain generic exception message including the level name.

  • result.result will be empty

Return type:

Result

duHast.Revit.Levels.purge_unused_level_types module

This module contains a number of helper functions relating to purging Revit levels and level heads.

duHast.Revit.Levels.purge_unused_level_types.get_unused_level_types_for_purge(doc)

Gets all ids of unused level types in the model. Unused: not one instance per level type is placed in the model. This method can be used to safely delete unused level types from the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A list of level type ids. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Levels.purge_unused_level_types.get_unused_level_head_families(doc)

Gets all ids of unused family symbols (types) of level head families. Unused: not one instance per symbol is placed in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A list of symbol ids. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Levels.purge_unused_level_types.get_unused_level_head_families_for_purge(doc)

Gets ids of all unused level head symbols and families. Unused: not one instance per level symbol is placed in the model. This method can be used to safely delete unused level symbols or families from the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A list of symbol and or family ids. :rtype: list of Autodesk.Revit.DB.ElementId

Module contents