Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.Annotation package

Subpackages

Submodules

duHast.Revit.Annotation.annotation module

A number of functions around Revit annotation objects.

duHast.Revit.Annotation.annotation.get_all_anno_symbol_types(doc)

Gets all annotation symbol types, area tag types, room tag types in the model

Parameters:

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

Returns:

list of types

Return type:

list

duHast.Revit.Annotation.annotation.get_anno_symbol_arrow_head_ids(doc)

Gets all arrow head ids used in annotation symbol types, area tag types, room tag types in the model.

Parameters:

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

Returns:

List of element ids representing arrow head symbols

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.annotation_copy module

Copies annotation samples.

duHast.Revit.Annotation.annotation_copy.copy_annotation_to_views(doc, source_dims_by_view_name, active_view, views_by_name_selected, callback_progress=None)

Copy annotation from one view to another.

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

  • source_dims_by_view_name (dict) – Dictionary containing the source annotations by target view name. ( not all annotations from the active view may want to be copied to all views )

  • active_view (Autodesk.Revit.DB.View) – The active view containing all source annotations

  • views_by_name_selected (dict) – Dictionary containing the selected views by name

  • callback_progress (ProgressBase) – Progress callback

Returns:

Result object

Return type:

Result

duHast.Revit.Annotation.arrow_heads module

A number of functions around Revit Arrow heads.

duHast.Revit.Annotation.arrow_heads.ARROWHEAD_PARAS_DIM = [Autodesk.Revit.DB.BuiltInParameter.DIM_STYLE_CENTERLINE_TICK_MARK, Autodesk.Revit.DB.BuiltInParameter.DIM_STYLE_INTERIOR_TICK_MARK, Autodesk.Revit.DB.BuiltInParameter.DIM_STYLE_LEADER_TICK_MARK, Autodesk.Revit.DB.BuiltInParameter.DIM_LEADER_ARROWHEAD, Autodesk.Revit.DB.BuiltInParameter.WITNS_LINE_TICK_MARK]

list of built in parameters attached to

  • text

  • independent tags

  • Annotation symbols

containing arrow head ids

duHast.Revit.Annotation.arrow_heads.ARROWHEAD_PARAS_TEXT = [Autodesk.Revit.DB.BuiltInParameter.LEADER_ARROWHEAD]

parameter containing the arrowhead id in text types

duHast.Revit.Annotation.arrow_heads.ARROWHEAD_PARAS_SPOT_DIMS = [Autodesk.Revit.DB.BuiltInParameter.SPOT_ELEV_LEADER_ARROWHEAD, Autodesk.Revit.DB.BuiltInParameter.SPOT_ELEV_SYMBOL]

list of built in parameters attached to spot dims containing arrow head ids and symbols used

duHast.Revit.Annotation.arrow_heads.ARROWHEAD_PARAS_STAIRS_PATH = [Autodesk.Revit.DB.BuiltInParameter.ARROWHEAD_TYPE]

list of built in parameters attached to stair path types containing arrow head ids

duHast.Revit.Annotation.arrow_heads.get_arrow_head_ids_from_type(doc, type_getter, parameter_list)

Gets all arrow head symbol ids used in dim types in a model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param type_getter: Function getting dimension types in the model. :type type_getter: func(doc) returns dim types. :param parameter_list: Names of parameters to be checked on dim types. :type parameter_list: list of str :return: List of element ids representing arrow head symbols :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.arrow_heads.get_arrow_types_in_model(doc)

Gets all arrow head types in the model. TODO: This uses a plain english name comparison to get arrow head types…may not work in non english versions of Revit! :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element types representing arrow heads. :rtype: list of Autodesk.Revit.DB.ElementType

duHast.Revit.Annotation.arrow_heads.get_arrow_type_ids_in_model(doc)

Gets all arrow type ids in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing arrow types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.dimensions module

This module contains a number of helper functions relating to dimensions.

duHast.Revit.Annotation.dimensions.get_dim_types(doc)

Gets all dimension types in a model :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A filtered element collector of Dimension Types :rtype: Autodesk.Revit.DB.FilteredElementCollector of DimensionType

duHast.Revit.Annotation.dimensions.get_dim_type_ids(doc)

Gets all dimension type ids in a model :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing Dimension Types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.dimensions.get_all_dimension_elements(doc)

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

duHast.Revit.Annotation.dimensions.get_symbol_ids_from_dim_types(doc)

Gets all family symbol ids used as centre line symbol from all dim styles in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing family symbols :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.dimensions.get_dim_type_arrow_head_ids(doc)

Gets all arrow head symbol ids used in dim types in a model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing arrow head symbols :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.generic_annotation module

Revit generic annotation helper functions.

duHast.Revit.Annotation.generic_annotation.get_all_generic_annotation_types_by_category(doc)

This will return a filtered element collector of all GenericAnnotation types in the model.

Parameters:

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

Returns:

_description_

Return type:

Autodesk.Revit.DB.FilteredElementCollector

duHast.Revit.Annotation.generic_annotation.get_all_generic_annotation_type_ids_by_category(doc)

This will return a list of all GenericAnnotation types (symbols) id’s in the model excluding shared families.

Parameters:

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

Returns:

_description_

Return type:

list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.independent_tags module

A number of functions around Revit independent tags.

duHast.Revit.Annotation.independent_tags.get_all_independent_tags(doc)

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

duHast.Revit.Annotation.independent_tags.get_independent_tag_type_arrow_head_ids(doc)

Gets all arrow head symbol ids used in independent tag types in a model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing arrow head symbols :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.independent_tags_elbow_properties module

A number of functions around Revit independent tags elbow properties.

duHast.Revit.Annotation.independent_tags_elbow_properties.get_elbow_properties(doc, tag, points_as_double=False)

Returns elbow properties depending on revit version.

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

  • tag (Autodesk.Revit.DB.IndependentTag) – The tag element

Returns:

A list of dictionaries with 3 keys: ELBOW_LOCATION, LEADER_END and LEADER_REFERENCE.

Return type:

[{str:Autodesk.Revit.DB.XYZ, str:Autodesk.Revit.DB.XYZ, str:Autodesk.Revit.DB Reference }]

duHast.Revit.Annotation.independent_tags_elbow_properties.get_elbow_properties_2021(tag, points_as_double)

Get elbow properties in revit versions up to revit 2022

Parameters:

tag (Autodesk.Revit.DB.IndependentTag) – The tag element

Returns:

A list of a single dictionaries with 3 keys: ELBOW_LOCATION, LEADER_END and LEADER_REFERENCE.

Return type:

[{str:Autodesk.Revit.DB.XYZ, str:Autodesk.Revit.DB.XYZ, str:Autodesk.Revit.DB Reference }]

duHast.Revit.Annotation.independent_tags_elbow_properties.get_elbow_properties_2022(tag, points_as_double)

Get elbow properties in revit versions from revit 2023 onwards

Parameters:

tag (Autodesk.Revit.DB.IndependentTag) – The tag element

Returns:

A list of dictionaries with 3 keys: ELBOW_LOCATION, LEADER_END and LEADER_REFERENCE.

Return type:

[{str:Autodesk.Revit.DB.XYZ, str:Autodesk.Revit.DB.XYZ, str:Autodesk.Revit.DB Reference }]

duHast.Revit.Annotation.independent_tags_modify_properties module

A number of functions around Revit independent tags.

class duHast.Revit.Annotation.independent_tags_modify_properties.move_tag(tag, new_location, old_location)

Bases: tuple

Create new instance of move_tag(tag, new_location, old_location)

new_location

Alias for field number 1

old_location

Alias for field number 2

tag

Alias for field number 0

duHast.Revit.Annotation.independent_tags_modify_properties.update_tag_location(doc, tag_data)

Moves all tags in dictionary to new location within one transaction

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

  • tag_data ({int:namedtuple move_tag}) – A dictionary containing tag data of tag to be moved

Returns:

Result class instance.

  • result.status. True if all tags where moved successfully, otherwise False.

  • result.message will contain ids of tags moved in format:’Moved tag: ‘ + id

  • result.result list of tags

On exception:

  • result.status (bool) will be False.

  • result.message will contain an exception message.

  • result.result will be empty

Return type:

Result

duHast.Revit.Annotation.independent_tags_modify_properties.update_tag_locations_from_report(doc, report_file_path, distance_threshold=50)

Reads a tag instance report and updates the location of tags in model with matching id if they have moved further then a given threshold distance.

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

  • report_file_path (str) – The fully qualified file path of the report file.

  • distance_threshold (int, optional) – The threshold distance, in mm, a tag has to move before it gets moved to a new location, defaults to 50. The distance is calculated by subtracting the current tag location from the one recorded in the report.

Returns:

Result class instance.

  • result.status. True if all tags where moved successfully, or no tags had to be moved, otherwise False.

  • result.message will contain ids of tags moved in format:’Moved tag: ‘ + id

  • result.result list of tags

On exception:

  • result.status (bool) will be False.

  • result.message will contain an exception message.

  • result.result will be empty

Return type:

Result

duHast.Revit.Annotation.independent_tags_tagged_elements module

A number of functions around Revit independent tags elements tagged properties.

duHast.Revit.Annotation.independent_tags_tagged_elements.get_tagged_elements(doc, tag)

Returns tagged element(s) depending on revit version.

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

  • tag (Autodesk.Revit.DB.IndependentTag) – The tag element

Returns:

A list of dictionaries representing the tagged object(s).

Dictionary has three keys:HOST_ELEMENT_ID,LINK_ELEMENT_ID,LINK_INSTANCE_ID If an exception occurs it will return a dictionary with same keys but None values.

Return type:

[{str:Autodesk.Revit.DB.ElementId}]

duHast.Revit.Annotation.independent_tags_tagged_elements.get_tagged_elements_2021(tag)

Get tagged element Id in revit versions up to revit 2022

Parameters:

tag (Autodesk.Revit.DB.IndependentTag) – The tag element

Returns:

A list with a single dictionary representing the tagged object.

Dictionary has three keys:HOST_ELEMENT_ID,LINK_ELEMENT_ID,LINK_INSTANCE_ID If an exception occurs it will return a dictionary with same keys but None values.

Return type:

[{str:Autodesk.Revit.DB.ElementId}]

duHast.Revit.Annotation.independent_tags_tagged_elements.get_tagged_elements_2022(tag)

Get elbow properties in revit versions from revit 2023 onwards

Parameters:

tag (Autodesk.Revit.DB.IndependentTag) – The tag element

Returns:

A list of dictionaries representing the tagged object(s).

Dictionary has three keys:HOST_ELEMENT_ID,LINK_ELEMENT_ID,LINK_INSTANCE_ID If an exception occurs it will return a dictionary with same keys but None values.

Return type:

[{str:Autodesk.Revit.DB.ElementId},]

duHast.Revit.Annotation.multi_ref_annotation module

This module contains a number of helper functions relating to multi reference annotation.

duHast.Revit.Annotation.multi_ref_annotation.get_all_multi_ref_annotation_types(doc)

Gets all multi reference annotation types in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A filtered element collector of MultiReferenceAnnotationType :rtype: Autodesk.Revit.DB.FilteredElementCollector of MultiReferenceAnnotationType

duHast.Revit.Annotation.multi_ref_annotation.get_all_multi_ref_annotation_type_ids(doc)

Gets all multi reference annotation type ids in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing multi reference Annotation Types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.multi_ref_annotation.get_all_multi_ref_annotation_elements(doc)

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

duHast.Revit.Annotation.multi_ref_annotation.get_all_similar_multi_reference_anno_types(doc)

Gets all multi reference annotation types using get similar types in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: list in format [[multi refType, [element ids of similar multi ref types, …]]] :rtype: List [[Autodesk.Revit.DB.ElementType, Autodesk.Revit.DB.ElementId, Autodesk.Revit.DB.ElementId,…],]

duHast.Revit.Annotation.purge_unused_annotation_types module

This module contains a number of helper functions relating to purging annotation types.

duHast.Revit.Annotation.purge_unused_annotation_types.get_used_text_type_ids_in_model(doc)

Gets all ids of text types used by elements in the model, includes types used in schedules (appearance)! Used: at least one instance of this type is placed in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing used text types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_used_dim_type_ids_in_model(doc)

Gets all used dimension type Ids in the model. Used: at least one instance using this type is placed in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing Dimension Types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_used_dim_styles_from_multi_ref(doc, multi_reference_anno_types)

Gets all dimension styles used in multi ref annotation types. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param multi_reference_anno_types: list in format [[multi refType, [element ids of similar multi ref types, …]]] :type multi_reference_anno_types: List [[Autodesk.Revit.DB.ElementType, [Autodesk.Revit.DB.ElementId, Autodesk.Revit.DB.ElementId,…],]] :return: List of element ids representing dimension style :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_used_multi_ref_dim_type_ids_in_model(doc)

Gets all ids of multi reference types used by elements in the model. Used: at least one instance using this type is placed in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing multi reference Annotation Types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_all_used_arrow_head_type_ids_in_model(doc)

Returns all used arrow types in the model. Used in types of dimension, text, independent tags, spot dims, annotation symbols (incl room and area tags), stairs path :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing arrow head symbols :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_all_unused_text_type_ids_in_model(doc)

Gets ID of all unused text types in the model. Unused: Not one instance of this type is placed in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing unused text types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_all_unused_dim_type_ids_in_model(doc)

Gets ID of all unused dim types in the model. Includes checking multi ref dims for used dim types. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing dimension types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_all_unused_multi_ref_dim_type_ids_in_model(doc)

Gets IDs of all unused multi ref dimension types in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing multi ref dimension types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_all_unused_arrow_type_ids_in_model(doc)

Gets all unused arrow type ids in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing arrow types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_unused_symbol_ids_from_spot_types(doc)

Gets all family symbol ids not used as symbol in any spot elevation or spot coordinate type definition. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing family symbols not used in spot elevation or spot coordinate type definition. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_unused_symbol_ids_from_spot_types_to_purge(doc)

Gets all unused family and family symbol ids of category BuiltInCategory.OST_SpotElevSymbols. This method can be used to safely delete unused families. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing family and family symbols not used in spot elevation or spot coordinate type definition. :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_used_generic_annotation_type_ids(doc)

Returns all used generic annotation symbol ids ( used in model as well as dimension types) :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: _description_ :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_unused_generic_annotation_type_ids(doc)

Returns all unused annotation symbol ids ( unused in model as well as dimension types) :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: _description_ :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.purge_unused_annotation_types.get_unused_generic_annotation_ids_for_purge(doc)

returns symbol(type) ids and family ids (when no type is in use) of in generic anno families which can be purged :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: _description_ :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.spot_dimensions module

This module contains a number of helper functions relating to spot annotation.

duHast.Revit.Annotation.spot_dimensions.get_all_spot_dim_types(doc)

Gets all spot Dim types in the model

Parameters:

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

Returns:

A filtered element collector of spot dimension types

Return type:

Autodesk.Revit.DB.FilteredElementCollector of spot dimension types

duHast.Revit.Annotation.spot_dimensions.get_symbol_ids_from_spot_types(doc)

Gets all family symbol ids used as a symbol from all spot elevation type definitions and spot coordinate type definitions. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing family symbols :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.spot_dimensions.get_all_spot_elevation_symbols_in_model(doc)

Gets all family symbols of category Spot Elevation Symbol in 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.Annotation.spot_dimensions.get_all_spot_elevation_symbol_ids_in_model(doc)

Gets all family symbol ids of category Spot Elevation Symbol in model :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing family symbols :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.spot_dimensions.get_spot_type_arrow_head_ids(doc)

returns all arrow head ids used in text types in a model

duHast.Revit.Annotation.stair_path module

This module contains a number of helper functions relating to stair path annotation.

duHast.Revit.Annotation.stair_path.get_all_stair_path_types(doc)

Gets all stairs path types in the model/ :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A filtered element collector of stair path types :rtype: Autodesk.Revit.DB.FilteredElementCollector of stair path types

duHast.Revit.Annotation.stair_path.get_stairs_path_arrow_head_ids(doc)

Gets all arrow head symbol ids used in stairs path types in a model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing arrow head symbols :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.text module

This module contains a number of helper functions relating to text.

duHast.Revit.Annotation.text.get_all_text_types(doc)

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

duHast.Revit.Annotation.text.get_all_text_type_ids(doc)

Gets all text type ids in the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing text types :rtype: list of Autodesk.Revit.DB.ElementId

duHast.Revit.Annotation.text.get_all_text_annotation_elements(doc)

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

duHast.Revit.Annotation.text.get_text_type_arrow_head_ids(doc)

Gets all arrow head ids used in text types in a model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: List of element ids representing arrow head symbols :rtype: list of Autodesk.Revit.DB.ElementId

Module contents