Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.Categories.Utility package

Submodules

duHast.Revit.Categories.Utility.category_properties_get_utils module

Revit sub-category property get functions .

duHast.Revit.Categories.Utility.category_properties_get_utils.get_category_graphic_style_ids(cat)

Returns a dictionary with keys: Projection, Cut, 3D and their respective ids :param cat: A category. :type cat: Autodesk.REvit.DB.Category :return: A dictionary :rtype: dictionary {str: Autodesk.Revit.DB.ElementId}

duHast.Revit.Categories.Utility.category_properties_get_utils.get_category_material(cat)

Returns the material properties name and id as a dictionary where key is property name and value the property id. :param cat: A category. :type cat: Autodesk.REvit.DB.Category :return: A dictionary :rtype: dictionary {str: Autodesk.Revit.DB.ElementId} If no material is assigned to a category it will return {‘None: Autodesk.Revit.DB.ElementId.InvalidElementId}

duHast.Revit.Categories.Utility.category_properties_get_utils.get_category_line_weights(cat)

Returns the line weight properties (cut and projection) as a dictionary where key is property description and value the property value :param cat: A category. :type cat: Autodesk.Revit.DB.Category :return: A dictionary. :rtype: dictionary {str: nullable integer}

duHast.Revit.Categories.Utility.category_properties_get_utils.get_category_colour(cat)

Returns the colour properties (RGB) and values as a dictionary where key is colour name and value the property value :param cat: A category. :type cat: Autodesk.Revit.DB.Category :return: A dictionary. :rtype: dictionary {str: byte}

duHast.Revit.Categories.Utility.category_properties_get_utils.get_category_properties(cat, doc)

Returns a dictionary where keys are category property names and value is the associated property value. :param cat: A category. :type cat: Autodesk.Revit.DB.Category :param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :return: A dictionary. :rtype: list [{str: var}]

duHast.Revit.Categories.Utility.category_properties_get_utils.get_saved_category_property_by_name(properties, prop_names)

Returns property values matching property names in saved category data. :param properties: List of dictionaries in format as per GetCategoryProperties(cat) method. :type properties: list [{str: var}] :param prop_names: List of property names of which the values are to be returned :type prop_names: list str :return: A list of values. :rtype: list var

duHast.Revit.Categories.Utility.category_properties_set_utils module

Revit sub-category property set functions .

duHast.Revit.Categories.Utility.category_properties_set_utils.set_category_material(doc, cat, material_id)

Updates material property of a given category. :param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :param cat: A category. :type cat: Autodesk.Revit.DB.Category :param material_id: The new material element id. :type material_id: Autodesk.Revit.DB.ElementId :return: True if material property was updated successfully, otherwise False. :rtype: bool

duHast.Revit.Categories.Utility.category_properties_set_utils.set_category_line_pattern(doc, cat, line_pattern_id, ignore_missing_cut_style)

Updates line pattern property of a given category. Note: in cases where the ‘cut’ property does not exist on a sub category this will return false even though the ‘projection’ property will most likely have been updated without a problem… :param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :param cat: A category. :type cat: Autodesk.Revit.DB.Category :param line_pattern_id: The newline pattern element id. :type line_pattern_id: Autodesk.Revit.DB.ElementId :param ignore_missing_cut_style: If true will not flag an exception if applying styles fails on missing cut style. :type ignore_missing_cut_style: bool :return: True if line pattern property was updated successfully, otherwise False. :rtype: bool

duHast.Revit.Categories.Utility.category_properties_set_utils.set_category_line_weights(doc, cat, line_thick_ness_cut, line_thickness_projection, ignore_missing_cut_style)

Updates line weight properties of a given category. :param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :param cat: A category. :type cat: Autodesk.Revit.DB.Category :param line_thick_ness_cut: The cut line weight. :type line_thick_ness_cut: int :param line_thickness_projection: The projection line weight. :type line_thickness_projection: int :param ignore_missing_cut_style: If true will not flag an exception if applying styles fails on missing cut style. :type ignore_missing_cut_style: bool :return: True if line weight property was updated successfully, otherwise False. :rtype: bool

duHast.Revit.Categories.Utility.category_properties_set_utils.set_category_colour(doc, cat, red, green, blue)

Updates colour properties of a given category. :param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :param cat: A category. :type cat: Autodesk.Revit.DB.Category :param red: The colour red channel. :type red: byte :param green: The colour green channel. :type green: byte :param blue: The colour blue channel. :type blue: byte :return: True if colour property was updated successfully, otherwise False. :rtype: bool

duHast.Revit.Categories.Utility.category_properties_set_utils.set_category_properties(doc, cat, properties, ignore_missing_cut_style)

Updates varies property values of a given category. :param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :param cat: A category. :type cat: Autodesk.Revit.DB.Category :param properties: List of property values to be applied to category. :type properties: list of dictionaries in format as per GetCategoryProperties(cat) method. :param ignore_missing_cut_style: If true will not flag an exception if applying styles fails on missing cut style. :type ignore_missing_cut_style: bool :return: True if all properties where updated successfully, otherwise False. :rtype: bool

duHast.Revit.Categories.Utility.category_property_names module

Revit category property names.

duHast.Revit.Categories.Utility.category_property_names.PROPERTY_MATERIAL_NAME = 'MaterialName'

category properties dictionary key names and default values material name

duHast.Revit.Categories.Utility.category_property_names.PROPERTY_MATERIAL_NAME_VALUE_DEFAULT = 'None'

material name default value

duHast.Revit.Categories.Utility.category_property_names.PROPERTY_MATERIAL_ID = 'MaterialId'

material id

duHast.Revit.Categories.Utility.category_property_names.PROPERTY_LINE_WEIGHT_PROJECTION_NAME = 'LineWeightProjection'

line weight projection name

duHast.Revit.Categories.Utility.category_property_names.PROPERTY_LINE_WEIGHT_CUT_NAME = 'LineWeightCut'

line weight cut name

duHast.Revit.Categories.Utility.category_property_names.PROPERTY_LINE_COLOUR_RED_NAME = 'Red'

line colour red name

duHast.Revit.Categories.Utility.category_property_names.PROPERTY_LINE_COLOUR_GREEN_NAME = 'Green'

line colour green name

duHast.Revit.Categories.Utility.category_property_names.PROPERTY_LINE_COLOUR_BLUE_NAME = 'Blue'

line colour blue name

duHast.Revit.Categories.Utility.category_property_names.CATEGORY_GRAPHIC_STYLE_PROJECTION = 'Projection'

graphic styles used for elements in families graphic style projection name

duHast.Revit.Categories.Utility.category_property_names.CATEGORY_GRAPHIC_STYLE_CUT = 'Cut'

graphic style cut name

duHast.Revit.Categories.Utility.category_property_names.CATEGORY_GRAPHIC_STYLE_3D = '3D'

graphic style 3D name

duHast.Revit.Categories.Utility.elements_by_category_utils module

Revit elements to category helper functions.

duHast.Revit.Categories.Utility.elements_by_category_utils.sort_elements_by_category(elements, element_dic)

Returns a dictionary of element ids where key is the category they belong to. :param elements: List of revit elements. :type elements: [Autodesk.Revit.DB.Element] :param element_dic: Dictionary where key is subcategory and values are element ids. :type element_dic: {Autodesk.Revit.DB.Category: [Autodesk.Revit.DB.ElementId]} :return: Dictionary where key is subcategory id and values are element ids. :rtype: {Autodesk.Revit.DB.ElementId: [Autodesk.Revit.DB.ElementId]}

duHast.Revit.Categories.Utility.elements_by_category_utils.sort_geometry_elements_by_category(elements, element_dic, doc)

Sorts geometry elements by their category in a Revit family document.

Args:

elements (list): A list of geometry elements to be sorted. element_dic (dict): A dictionary where the sorted elements will be stored. doc (Revit Document): The current Revit family document.

Returns:

dict: A dictionary where the keys are category ids and the values are lists of element ids. The geometry elements are sorted by their category.

duHast.Revit.Categories.Utility.elements_by_category_utils.get_elements_by_category(doc, cat)

Returns elements in family assigned to a specific category :param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :param cat: A category. :type cat: Autodesk.Revit.DB.Category :return: Dictionary where key is subcategory and values are element ids. :rtype: {Autodesk.Revit.DB.Category: [Autodesk.Revit.DB.ElementId]}

duHast.Revit.Categories.Utility.elements_by_category_utils.move_elements_to_category(doc, elements, to_category_name, destination_cat_ids)

Moves elements provided in a dictionary to another category specified by name.

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

  • elements ({Autodesk.Revit.DB.Category: [Autodesk.Revit.DB.ElementId]}) – Dictionary of elements, where keys are graphic style names.

  • to_category_name (str) – The name of the subcategory elements are to be moved to.

  • destination_cat_ids (dictionary {str: Autodesk.Revit.DB.ElementId}) – Dictionary of IDs of graphic styles, where keys are graphic style names.

Returns:

Result class instance. - result.status (bool): True if all elements were moved to destination subcategories, otherwise False. - result.message (str): Contains the name of the destination subcategory by element. - result.result (empty list)

On exception:
  • result.status (bool): False.

  • result.message (str): Contains a generic exception message.

  • result.result (empty list)

Return type:

Result

duHast.Revit.Categories.Utility.elements_by_category_utils.move_elements_from_sub_category_to_sub_category(doc, from_category_name, to_category_name)

Moves elements from one subcategory to another one identified by their names.

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

  • from_category_name (str) – The source subcategory name.

  • to_category_name (str) – The destination subcategory name.

Returns:

Result class instance. - result.status (bool): True if all elements from the source subcategory were moved to the destination subcategory, otherwise False. - result.message (str): Contains the name of the destination subcategory by element. - result.result (empty list)

On exception:
  • result.status (bool): False.

  • result.message (str): Contains a generic exception message.

  • result.result (empty list)

Return type:

Result

duHast.Revit.Categories.Utility.elements_by_category_utils.get_used_category_ids(doc)

Returns all category ids in a family which have an element assigned to them :param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :return: List of categories. :rtype: [Autodesk.Revit.DB.Category]

Module contents