Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.LinePattern package

Subpackages

Submodules

duHast.Revit.LinePattern.fill_patterns module

Revit fill patterns helper functions.

duHast.Revit.LinePattern.fill_patterns.get_all_fill_pattern(doc)

Gets all fill pattern elements in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A filtered element collector of all fill pattern elements. :rtype: Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.LinePattern.fill_patterns.pattern_ids_by_name(doc)

Returns a dictionary where fill pattern name is key, values are all ids of line patterns with the exact same name.

Parameters:

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

Returns:

A dictionary where fill pattern name is key, values are all ids of line patterns with the exact same name

Return type:

dictionary(key str, value list of Autodesk.Revit.DB.ElementId)

duHast.Revit.LinePattern.fill_patterns.get_used_pattern_ids_in_filled_region_types(doc)

Returns a list of all fill pattern ids used in filled region types in the model.

Parameters:

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

Returns:

A list of all fill pattern ids used in filled region types in the model.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.LinePattern.line_patterns module

Revit line line patterns helper functions.

duHast.Revit.LinePattern.line_patterns.PROPERTY_PATTERN_NAME = 'PatternName'

pattern name

duHast.Revit.LinePattern.line_patterns.PROPERTY_PATTERN_NAME_VALUE_DEFAULT = 'Solid'

pattern name default value, hard coded solid line pattern name

duHast.Revit.LinePattern.line_patterns.PROPERTY_PATTERN_ID = 'PatternId'

pattern id

duHast.Revit.LinePattern.line_patterns.get_line_pattern_from_category(cat, doc)

Returns the line pattern properties as a dictionary where keys are pattern name and pattern id.

Parameters:
  • cat (Autodesk.REvit.DB.Category) – A category.

  • doc (Autodesk.Revit.DB.Document) – Current Revit family document.

Returns:

A dictionary.

Return type:

dictionary {str: str, str: Autodesk.Revit.DB.ElementId}

duHast.Revit.LinePattern.line_patterns.get_line_pattern_from_level_element(doc, level)

Returns the line pattern properties as a dictionary where keys are pattern name and pattern id.

Parameters:
  • doc (Current Revit family document.) – Current Revit family document.

  • level (Autodesk.Revit.DB.Level) – a level element

Returns:

A dictionary.

Return type:

dictionary {str: str, str: Autodesk.Revit.DB.ElementId}

duHast.Revit.LinePattern.line_patterns.delete_line_patterns_contains(doc, contains)

Deletes all line patterns where the names contains a provided string

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

  • contains (str) – Filter: pattern name needs to contain this string to be deleted.

Returns:

Result class instance.

  • .status True if line pattern where deleted successfully. Otherwise False.

  • .message will contain delete status per pattern.

Return type:

Result

duHast.Revit.LinePattern.line_patterns.delete_line_pattern_starts_with(doc, starts_with)

Deletes all line patterns where the name starts with provided string.

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

  • starts_with (str) – Filter: pattern name needs to start with this string to be deleted.

Returns:

Result class instance.

  • .status True if line pattern where deleted successfully. Otherwise False.

  • .message will contain delete status per pattern.

Return type:

Result

duHast.Revit.LinePattern.line_patterns.delete_line_patterns_without(doc, contains)

Deletes all line patterns where the name does not contain the provided string.

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

  • contains (str) – Filter: pattern name needs not to contain this string to be deleted.

Returns:

Result class instance.

  • .status True if line pattern where deleted successfully. Otherwise False.

  • .message will contain delete status per pattern.

Return type:

Result

duHast.Revit.LinePattern.line_patterns.get_all_line_patterns(doc)

Gets all line patterns in the model.

Parameters:

doc (_type_) – _description_

Returns:

filtered element collector of all line pattern elements in model.

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.LinePattern.line_patterns.build_patterns_dictionary_by_name(doc)

Returns a dictionary where line pattern name is key, values are all ids of line patterns with the exact same name.

Parameters:

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

Returns:

A dictionary where line pattern name is key, values are all ids of line patterns with the exact same name

Return type:

dictionary(key str, value list of Autodesk.Revit.DB.ElementId)

duHast.Revit.LinePattern.line_patterns.delete_duplicate_line_patter_names(doc)

Deletes all but the first line pattern by Id with the exact same name.

Parameters:

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

Returns:

Result class instance.

  • .status True if all views where deleted. Otherwise False.

  • .message will contain deletion status.

Return type:

Result

duHast.Revit.LinePattern.line_styles module

Revit line line styles helper functions.

duHast.Revit.LinePattern.line_styles.delete_line_styles_starts_with(doc, starts_with)

Deletes all line styles where the name starts with provided string

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

  • starts_with (str) – Filter: style name needs to start with this string to be deleted.

Returns:

Result class instance.

  • .status True if all views where deleted. Otherwise False.

  • .message will contain deletion status.

Return type:

Result

duHast.Revit.LinePattern.line_styles.get_all_line_style_ids(doc)

Gets all line styles ids in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A list of all line style ids. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.LinePattern.line_styles.get_all_graphics_style_ids_by_line_style_id(doc)

Gets all graphics style ids by line style id in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A dictionary of all line style ids as integer values with their corresponding graphics style ids as integer values. :rtype: dict

duHast.Revit.LinePattern.purge_unused_fill_patterns_by_delete module

Revit purging not used fill pattern styles using purge by delete helper functions.

duHast.Revit.LinePattern.purge_unused_fill_patterns_by_delete.get_fill_pattern_ids(doc, element_ids=None, element_ids_list_is_inclusive_filter=True)

Returns all fill pattern ids in the model.

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

  • element_ids ([Autodesk.Revit.DB.ElementId]) – optional list of fill pattern element ids

  • element_ids_list_is_inclusive_filter (bool) – If true and element_ids list has values only those patterns will be purged if possible. If false and element_ids list has values any patterns in the list will not be purged.

Returns:

A list of all fill pattern ids in the model.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.LinePattern.purge_unused_fill_patterns_by_delete.purge_fill_pattern_by_delete(doc, progress_callback=None, debug=False, element_ids=None, element_ids_list_is_inclusive_filter=True)

Purge fill pattern by delete.

Note: This is a very slow process and can take a few hours to complete depending on the size of the model and the number of fill patterns.

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

  • progress_callback (callable) – Callback to report progress.

  • debug (bool) – Debug mode.

  • element_ids ([Autodesk.Revit.DB.ElementId]) – optional list of fill pattern element ids

  • element_ids_list_is_inclusive_filter (bool) – If true and element_ids list has values only those fill patterns will be purged if possible. If false and element_ids list has values any fill patterns in the list will not be purged.

Returns:

Result class instance.

  • .status True if unused fill pattern where deleted or nothing needed to be deleted. Otherwise False.

  • .message will contain deletion status.

duHast.Revit.LinePattern.purge_unused_line_patterns_by_delete module

Revit purging not used line pattern styles using purge by delete helper functions.

duHast.Revit.LinePattern.purge_unused_line_patterns_by_delete.get_line_pattern_ids(doc, element_ids=None, element_ids_list_is_inclusive_filter=True)

Returns all line pattern ids in the model.

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

  • element_ids ([Autodesk.Revit.DB.ElementId]) – optional list of shared parameter element ids

  • element_ids_list_is_inclusive_filter (bool) – If true and element_ids list has values only those line patterns will be purged if possible. If false and element_ids list has values any line patterns in the list will not be purged.

Returns:

A list of all line pattern ids in the model.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.LinePattern.purge_unused_line_patterns_by_delete.purge_line_pattern_by_delete(doc, progress_callback=None, debug=False, element_ids=None, element_ids_list_is_inclusive_filter=True)

Purge line pattern by delete.

Note: This is a very slow process and can take a few hours to complete depending on the size of the model and the number of line patterns.

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

  • progress_callback (callable) – Callback to report progress.

  • debug (bool) – Debug mode.

  • element_ids ([Autodesk.Revit.DB.ElementId]) – optional list of shared parameter element ids

  • element_ids_list_is_inclusive_filter (bool) – If true and element_ids list has values only those parameters will be purged if possible. If false and element_ids list has values any parameters in the list will not be purged.

Returns:

Result class instance.

  • .status True if unused line pattern where deleted or nothing needed to be deleted. Otherwise False.

  • .message will contain deletion status.

duHast.Revit.LinePattern.purge_unused_line_styles_by_delete module

Revit purging not used line styles by using the purge by delete helper functions.

duHast.Revit.LinePattern.purge_unused_line_styles_by_delete.get_line_style_ids(doc, element_ids=None, element_ids_list_is_inclusive_filter=True)

Returns all line style ids in the model.

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

  • element_ids ([Autodesk.Revit.DB.ElementId]) – optional list of line style element ids

  • element_ids_list_is_inclusive_filter (bool) – If true and element_ids list has values only those line styles will be purged if possible. If false and element_ids list has values any line styles in the list will not be purged.

Returns:

A list of all line styles ids in the model.

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.LinePattern.purge_unused_line_styles_by_delete.purge_line_styles_by_delete(doc, progress_callback=None, debug=False, element_ids=None, element_ids_list_is_inclusive_filter=True)

Purge line styles by delete.

Note: This is a quick(ish) process and can take a few minutes to complete depending on the size of the model and the number of line styles.

Observations:

  • when deleting a line style in Revit, the associated graphics style will be deleted as well. Which leads to a minimum of 2 deleted elements per line style.

  • a custom element deleted modifier is used to check if the deleted element count is 2 and if the second deleted element is the associated graphics style.

  • if that is the case and no modified elements are listed, the deleted element count is reduced to 1 and the line style is considered as deleted.

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

  • progress_callback (callable) – Callback to report progress.

  • debug (bool) – Debug mode.

  • element_ids ([Autodesk.Revit.DB.ElementId]) – optional list of line style element ids

  • element_ids_list_is_inclusive_filter (bool) – If true and element_ids list has values only those line styles will be purged if possible. If false and element_ids list has values any line styles in the list will not be purged.

Returns:

Result class instance.

  • .status True if unused line styles where deleted or nothing needed to be deleted. Otherwise False.

  • .message will contain deletion status.

Module contents