Sample Code Revit Batch Processor 1.1.11 documentation

Contents:

This Page

duHast.Revit.Family.Data package

Subpackages

Submodules

duHast.Revit.Family.Data.family_base_data_circular_referencing module

Family Base data analysis module containing functions to find circular family referencing in extracted data.

A circular reference is when a family A has a family B nested but family B has also family A nested.

Algorithm description:

  • read families into data family objects

  • process them ( to get the internal nesting set up)

  • get the shortest path from each family

  • check for duplicates in those paths ( may need to get unique path for name and category!)

duHast.Revit.Family.Data.family_base_data_circular_referencing.find_circular_reference(family_data, result_list)

Function to find circular references in families.

Parameters:
  • family_data (list) – list of family data objects

  • result_list (list of tuples with two entries (0 index the family_data_family object, 1 index list of tuples with two entries in format, 0 index the nesting level as integer at which the circular nesting occurs, 1 index a string in format family name :: family category )) – list to store families with circular references

Returns:

list of tuples containing family with circular references at 0 and circular family data at 1

duHast.Revit.Family.Data.family_base_data_circular_referencing.check_families_have_circular_references(family_base_data_report_file_path)

Function to check if families have circular references.

Parameters:

family_base_data_report_file_path (str) – path to the family base data report file

Returns:

result object

Return type:

Result

duHast.Revit.Family.Data.family_base_data_missing_families module

Family Base data analysis module containing functions to find missing families.

A missing family is a family which is not present in the family base data report as a root family but present as a nested family.

Algorithm description:

  • read base data file processing list

duHast.Revit.Family.Data.family_base_data_missing_families.get_unique_nested_families_from_path_data(path_data)

Function to retrieve unique nested families from a list of tuples representing longest unique name nesting path and matching longest unique category nesting path.

Parameters:

path_data (list[(family_name_nesting, family_category_nesting)]) – list of tuples representing longest unique name nesting path and matching longest unique category nesting path

Returns:

list of tuples containing unique family name and category

Return type:

list[(family_name, family_category)]

duHast.Revit.Family.Data.family_base_data_missing_families.get_unique_root_families_from_family_data(family_data)

Function to retrieve unique root families from a list of family data objects.

Parameters:

family_data (list[FamilyDataFamily]) – list of family data objects

Returns:

list of tuples containing family name and category

Return type:

list[(family_name, family_category)]

duHast.Revit.Family.Data.family_base_data_missing_families.get_missing_families(root_families, nested_families)

Function to find missing families from a list of root families and nested families.

Parameters:
  • root_families (list[(family_name, family_category)]) – list of tuples representing root family name and category

  • nested_families (list[(family_name, family_category)]) – list of tuples representing nested family name and category

Returns:

list of tuples representing nested family name and category which does not have a matching root family

Return type:

list[(family_name, family_category)]

duHast.Revit.Family.Data.family_base_data_missing_families.process_families(family_data, result_list)

Function to retrieve longest unique nesting path data from families.

Parameters:
  • family_data (list) – list of family data objects

  • result_list (list[(family, (family_name_nesting, family_category_nesting))]) – list to store longest unique path

Returns:

list of tuples containing family data object at 0 and longest path at 1 (multiple entries per family possible). Longest path itself is a tuple of family name and category.

duHast.Revit.Family.Data.family_base_data_missing_families.check_families_missing_from_library(family_base_data_report_file_path)

Processes a family base data report and identifies any nested families which have not been processed as a root family and therefore do not exist in the library.

Parameters:

family_base_data_report_file_path (str) – Fully qualified file path to family base data report file.

Returns:

Result class instance.

  • result.status. True if missing families where found without an exception occurring.

  • result.message will contain the summary messages of the process including time stamps.

  • result.result [(nested_family_name, nested_family_category)]

On exception:

  • result.status (bool) will be False.

  • result.message will contain generic exception message.

  • result.result will be empty

Return type:

Result

duHast.Revit.Family.Data.family_base_data_missing_families.get_direct_root_families(families, missing_families)

Returns a list of FamilyDataFamily instances which represent the direct parents (host families) of the missing families.

Parameters:
  • families ([FamilyDataFamily]) – List of family instances

  • missing_families ([(family name, family category)]) – List of tuples representing the name and category of a family missing (from the library and therefore not presented as root family)

Returns:

List of family instances which represent the direct parents (host families) of the missing families

Return type:

[FamilyDataFamily]

duHast.Revit.Family.Data.family_base_data_missing_families.find_missing_families_direct_host_families(family_base_data_report_file_path)

Returns a list of FamilyDataFamily instances which represent the direct parents (host families) of the missing families. Only processed root families which have a missing family as a direct nested family are returned. (any root families which contains a missing family nested further down the nesting tree are not returned)

Parameters:

family_base_data_report_file_path (str) – Fully qualified file path to family base data report file.

Returns:

Result class instance.

  • result.status. True if host families of missing families where found without an exception occurring.

  • result.message will contain the summary messages of the process including time stamps.

  • result.result [FamilyDataFamily]

On exception:

  • result.status (bool) will be False.

  • result.message will contain generic exception message.

  • result.result will be empty

Return type:

Result

duHast.Revit.Family.Data.family_base_data_reload_advanced_deprecated module

Family Base data analysis module containing functions to build a reload tree.

  • read change list:

  • text file (tab separated) with columns:familyName familyFilePath categoryName

  • read overall family base data list

  • get direct parents of change list families

  • get next level parents of direct parents

  • loop direct parent list until empty:

    • remove any direct parents which also exist in next level parents

    • write direct parents to file

    • set next level parents as direct parents

    • find all direct parents of changed families in base data list

  • those reload lists will then be separated into work chunks by file list writer…

duHast.Revit.Family.Data.family_base_data_reload_advanced_deprecated.build_work_lists(change_list_file_path, family_base_data_report_file_path, load_lists_output_directory_path)

Processes a file change list and a family base data report. From both reports it builds a lists for reloading families bottom up in their nesting hierarchy.

Parameters:
  • change_list_file_path (str) – Fully qualified file path to family change list report file.

  • family_base_data_report_file_path (str) – Fully qualified file path to family base data report file.

  • load_lists_output_directory_path (str) – Fully qualified directory path to which the task output files will be written

Raises:

Exception – “Infinite loop.” Will be raised if more then 20 task output files are written (representing a family nesting level of 20 deep…unlikely)

duHast.Revit.Family.Data.family_base_data_utils_deprecated module

Family Base data utility module containing functions to read the data from file.

Reads family base data into two list of named tuples.

root_family:

  • name

  • category

  • filePath

  • parent

  • child

nested_family:

  • name

  • category

  • filePath

  • rootPath [str]

  • categoryPath [str]

class duHast.Revit.Family.Data.family_base_data_utils_deprecated.root_family(name, category, filePath, parent, child, report_data)

Bases: tuple

Create new instance of root_family(name, category, filePath, parent, child, report_data)

category

Alias for field number 1

child

Alias for field number 4

filePath

Alias for field number 2

name

Alias for field number 0

parent

Alias for field number 3

report_data

Alias for field number 5

class duHast.Revit.Family.Data.family_base_data_utils_deprecated.nested_family(name, category, filePath, rootPath, categoryPath, hostFamily, report_data)

Bases: tuple

Create new instance of nested_family(name, category, filePath, rootPath, categoryPath, hostFamily, report_data)

category

Alias for field number 1

categoryPath

Alias for field number 4

filePath

Alias for field number 2

hostFamily

Alias for field number 5

name

Alias for field number 0

report_data

Alias for field number 6

rootPath

Alias for field number 3

duHast.Revit.Family.Data.family_base_data_utils_deprecated.read_overall_family_data_list(file_path)

Reads list of families from family base data report file into named tuples.

Parameters:

file_path (str) – Fully qualified file path to family base data report file.

Raises:
  • Exception – “Families base data list files does not exist.”

  • Exception – “Empty Families base data list file!”

Returns:

Two lists: first list of named tuples contain family root data, second list contains family nested data.

Return type:

[root_family], [nested_family]

duHast.Revit.Family.Data.family_base_data_utils_deprecated.read_overall_family_data_list_from_directory(directory_path)

Reads the first family base data file it finds in a folder. Note: This method calls ReadOverallFamilyDataList(filePath) which will raise exceptions if files are empty or dont exist in specified folder.

Parameters:

directory_path (_str) – A fully qualified directory path containing family base data file(s)

Returns:

Two lists: first list of named tuples contain family root data, second list contains family nested data.

Return type:

[root_family], [nested_family]

duHast.Revit.Family.Data.family_base_data_utils_deprecated.read_overall_family_data_list_into_nested(file_path)

Reads list of families from family base data report file into named tuples.

Parameters:

file_path (str) – Fully qualified file path to family base data report file.

Raises:
  • Exception – “Families base data list files does not exist.”

  • Exception – “Empty Families base data list file!”

Returns:

A list contains family nested data.

Return type:

[nested_family]

duHast.Revit.Family.Data.family_base_data_utils_deprecated.read_overall_family_data_list_into_nested_from_directory(directory_path)

Reads the first family base data file it finds in a folder. Note: This method calls ReadOverallFamilyIntoNestedDataList(filePath) which will raise exceptions if files are empty or dont exist in specified folder.

Parameters:

directory_path (_str) – A fully qualified directory path containing family base data file(s)

Returns:

A list contains family nested data.

Return type:

[nested_family]

duHast.Revit.Family.Data.family_base_data_utils_deprecated.cull_nested_base_data_blocks(root_families, nested_families)

Reduce base data families for parent / child finding purposes. Keep the nodes with the root path longes branch only.

Sample ( within a single data block)

famA :: famB :: famC FamA :: famB

The second of the above examples can be culled since the path is contained within the first example.

Sample ( across multiple data blocks)

famA :: famB :: famC famB :: famC

The second of the above examples can be culled since the first family (famB) in that sample is already in the first example.(nested Family)

Parameters:

overall_family_base_nested_data (_type_) – _description_

duHast.Revit.Family.Data.family_base_data_utils_deprecated.get_nested_family_data_for_root_family(root_families, nested_families)

Returns a list of nested families for each root family.

Parameters:
  • root_families ([root_family]) – A list of tuples containing root family data.

  • nested_families ([nested_family]) – A list of tuples containing nested family data.

Returns:

A dictionary where:

  • key is the root family name and category concatenated and

  • value is a list of tuples containing nested family data.

Return type:

{str: [nested_family]}

duHast.Revit.Family.Data.family_base_data_utils_deprecated.find_root_families_not_in_nested_data(root_families, nested_families)

Returns a list of root families not found in the nested family data set.

In order to reduce the number of families to be processed, this function can be used to find the root families which are not nested into any other family and therefore do contain the longest nesting path.

This is based on two assumptions:

  • The provided data set contains all families in the project (no missing families are reported)

  • As soon as a family is nested into another family, its nesting path will appear in the nested family data set and the root family data set.

Parameters:
  • root_families ([root_family]) – A list of tuples containing root family data.

  • nested_families ([nested_family]) – A list of tuples containing nested family data.

Returns:

A list of tuples containing root family data.

Return type:

[root_family]

duHast.Revit.Family.Data.family_base_data_utils_deprecated.find_direct_host_families(nested_fam, overall_family_base_nested_data)

Finds the direct hosts of the past in family in the base nested family data set.

Parameters:
  • nested_fam (nested_family) – A tuple containing nested family data.

  • overall_family_base_nested_data ([nested_family]) – List of tuples containing nested family data.

Returns:

A dictionary where:

  • key is the family name and category concatenated and

  • value is a tuple in format 0: family name, 1: family category

Return type:

{str: (str,str)}

duHast.Revit.Family.Data.family_base_data_utils_deprecated.find_all_direct_host_families(families, overall_family_base_nested_data)

Returns a dictionary of all direct host families of families past in.

Parameters:
  • families ([nested_family]) – A list of tuples containing nested family data.

  • overall_family_base_nested_data ([nested_family]) – List of tuples containing nested family data.

Returns:

A dictionary.

Return type:

{str: (str,str)}

duHast.Revit.Family.Data.family_base_data_utils_deprecated.find_root_families_from_hosts(host_families, overall_family_base_root_data)

Returns a list of tuples of type root_family matching the past in host families.

Parameters:
  • host_families ({str: (str,str)}) –

    A dictionary where:

    • key is the family name and category concatenated and

    • value is a tuple in format 0: family name, 1: family category

  • overall_family_base_root_data ([root_family]) – List of tuples containing root family data.

Returns:

List of root family tuples.

Return type:

[root_family]

duHast.Revit.Family.Data.family_category_data_utils_deprecated module

Family Category data utility module containing functions to read category data from file.

Reads family category data into list of named tuples.

root_family:

  • name

  • category

  • filePath

  • parent

  • child

  • subcategories

nested_family:

  • name

  • category

  • filePath

  • rootPath

  • categoryPath

  • hostFamily

  • subcategories

reads change category directives into list of named tuples:

change_family_category:

  • filePath

  • newCategoryName

class duHast.Revit.Family.Data.family_category_data_utils_deprecated.change_family_category(filePath, newCategoryName)

Bases: tuple

Create new instance of change_family_category(filePath, newCategoryName)

filePath

Alias for field number 0

newCategoryName

Alias for field number 1

class duHast.Revit.Family.Data.family_category_data_utils_deprecated.change_family_sub_category(familyCategory, oldSubCategoryName, newSubCategoryName)

Bases: tuple

Create new instance of change_family_sub_category(familyCategory, oldSubCategoryName, newSubCategoryName)

familyCategory

Alias for field number 0

newSubCategoryName

Alias for field number 2

oldSubCategoryName

Alias for field number 1

class duHast.Revit.Family.Data.family_category_data_utils_deprecated.graphic_property_rgb(red, green, blue)

Bases: tuple

Create new instance of graphic_property_rgb(red, green, blue)

blue

Alias for field number 2

green

Alias for field number 1

red

Alias for field number 0

class duHast.Revit.Family.Data.family_category_data_utils_deprecated.graphic_property_line_weight(cut, projection)

Bases: tuple

Create new instance of graphic_property_line_weight(cut, projection)

cut

Alias for field number 0

projection

Alias for field number 1

class duHast.Revit.Family.Data.family_category_data_utils_deprecated.graphic_property_material(id, name)

Bases: tuple

Create new instance of graphic_property_material(id, name)

id

Alias for field number 0

name

Alias for field number 1

duHast.Revit.Family.Data.family_category_data_utils_deprecated.graphic_property_three_d_cut_projection

alias of graphicProperty

duHast.Revit.Family.Data.family_category_data_utils_deprecated.sub_category_properties_container

alias of subCategoryProperties

class duHast.Revit.Family.Data.family_category_data_utils_deprecated.sub_category(parentCategoryName, subCategoryName, subCategoryId, usageCounter, usedBy, subCategoryProperties)

Bases: tuple

Create new instance of sub_category(parentCategoryName, subCategoryName, subCategoryId, usageCounter, usedBy, subCategoryProperties)

parentCategoryName

Alias for field number 0

subCategoryId

Alias for field number 2

subCategoryName

Alias for field number 1

subCategoryProperties

Alias for field number 5

usageCounter

Alias for field number 3

usedBy

Alias for field number 4

class duHast.Revit.Family.Data.family_category_data_utils_deprecated.root_family(name, category, filePath, parent, child, subcategories)

Bases: tuple

Create new instance of root_family(name, category, filePath, parent, child, subcategories)

category

Alias for field number 1

child

Alias for field number 4

filePath

Alias for field number 2

name

Alias for field number 0

parent

Alias for field number 3

subcategories

Alias for field number 5

class duHast.Revit.Family.Data.family_category_data_utils_deprecated.nested_family(name, category, filePath, rootPath, categoryPath, hostFamily, subcategories)

Bases: tuple

Create new instance of nested_family(name, category, filePath, rootPath, categoryPath, hostFamily, subcategories)

category

Alias for field number 1

categoryPath

Alias for field number 4

filePath

Alias for field number 2

hostFamily

Alias for field number 5

name

Alias for field number 0

rootPath

Alias for field number 3

subcategories

Alias for field number 6

duHast.Revit.Family.Data.family_category_data_utils_deprecated.EXCEPTION_EMPTY_FAMILY_SUBCATEGORY_DATA_FILES = 'Empty Families subcategory data list file!'

dataRGB = graphic_property_rgb(120,120,120) dataLineWeight = graphic_property_line_weight(3,6) dataMaterial = graphic_property_material(-1,’’) dataGraphic = graphic_property_three_d_cut_projection(None,None,None) # combine into a container dataSubPropertiesContainer = sub_category_properties_container (dataRGB, dataLineWeight, dataMaterial, dataGraphic) # set up the actual sub category ( single row in report ) dataSubCatSample = sub_category(‘Parent Cat Name’, ‘subCat name’, 1234, dataSubPropertiesContainer) # set up a root family tuple dataRootFam = root_family(‘root family name’, ‘root family category’, ‘file path’, [], [], [dataSubCatSample]) # set up a nested family tuple dataNestedFam = nested_family(‘nested family name’, ‘nested family category’, ‘file path’, ‘root Path’, ‘category Path’,’host Family data’, [dataSubCatSample])

duHast.Revit.Family.Data.family_category_data_utils_deprecated.read_overall_family_data_list(file_path)

Reads list of families from family category data report file into named tuples.

Parameters:

file_path (str) – Fully qualified file path to family category data report file.

Raises:
  • Exception – “Families category data list files does not exist.”

  • Exception – “Empty Families category data list file!”

Returns:

Two lists: first list of named tuples contain family root data, second list contains family nested data.

Return type:

[root_family], [nested_family]

duHast.Revit.Family.Data.family_category_data_utils_deprecated.read_overall_family_category_data_from_directory(directory_path)

Reads the first family category data file it finds in a folder. Note: This method calls ReadOverallFamilyDataList(filePath) which will raise exceptions if files are empty or dont exist in specified folder.

Parameters:

directory_path (_str) – A fully qualified directory path containing family category data file(s)

Returns:

Two lists: first list of named tuples contain family root data, second list contains family nested data.

Return type:

[root_family], [nested_family]

duHast.Revit.Family.Data.family_category_data_utils_deprecated.read_overall_change_category_directives_list(file_paths)

Reads list of family change category directives from files into named tuples.

Parameters:

file_path ([str]) – List of fully qualified file path to family change category directive file.

Raises:
  • Exception – “Families change directive list files do not exist.”

  • Exception – “Empty Families category data list file!”

Returns:

List of named tuples contain family category change directive.

Return type:

[change_family_category]

duHast.Revit.Family.Data.family_category_data_utils_deprecated.read_overall_family_category_change_directives_from_directory(directory_path)

Reads all category change directive file it finds in a folder. Note: This method calls ReadOverallFamilyDataList(filePath) which will raise exceptions if files are empty or dont exist in specified folder.

Parameters:

directory_path (_str) – A fully qualified directory path containing family category change directive file(s)

Returns:

list of named tuples contain family category change directives.

Return type:

[change_family_category]

duHast.Revit.Family.Data.family_category_data_utils_deprecated.read_overall_family_sub_category_change_directives_from_directory(directory_path)

Reads all subcategory change directive file it finds in a folder. Note: This method calls ReadOverallFamilyDataList(filePath) which will raise exceptions if files are empty or dont exist in specified folder.

Parameters:

directory_path (_str) – A fully qualified directory path containing family category change directive file(s)

Returns:

list of named tuples contain family sub category change directives.

Return type:

[change_family_sub_category]

duHast.Revit.Family.Data.family_category_data_utils_deprecated.read_overall_change_sub_category_directives_list(file_paths)

Reads list of family change subcategory directives from files into named tuples.

Parameters:

file_path ([str]) – List of fully qualified file path to family change category directive file.

Raises:
  • Exception – _EXCEPTION_NO_FAMILY_SUBCATEGORY_DATA_FILES

  • Exception – _EXCEPTION_EMPTY_FAMILY_SUBCATEGORY_DATA_FILES

Returns:

List of named tuples containing family subcategory change directive.

Return type:

[change_family_sub_category]

duHast.Revit.Family.Data.family_category_data_utils_deprecated.get_families_requiring_sub_category_change(root_families, sub_cat_change_directives)

Returns a list of file path of root families containing subcategories requiring a rename.

Note: list of file path returned is unique: i.e. if a family has multiple matches for rename subcategory directives it will still only appear once in the list.

Parameters:
Returns:

List of family file path.

Return type:

[str]

duHast.Revit.Family.Data.family_data_family_processor_utils module

Family Base data processing utility module.

Processes family_data_family objects using multi threading ( testing has shown results in multi threading are not as expected, so single core processing is used for now)

duHast.Revit.Family.Data.family_data_family_processor_utils.process_data(family_base_data_report_file_path, do_this)

duHast.Revit.Family.Data.family_reload_advanced_utils module

Reload using advanced tools collection.

This module provides utility functions to read and write reload task lists for the Revit Batch Processor.

class duHast.Revit.Family.Data.family_reload_advanced_utils.changed_family(name, category, filePath)

Bases: tuple

Create new instance of changed_family(name, category, filePath)

category

Alias for field number 1

filePath

Alias for field number 2

name

Alias for field number 0

duHast.Revit.Family.Data.family_reload_advanced_utils.write_reload_list_to_file(reload_families, directory_path, counter=0)

Writes task list file to disk. File contains single column of fully qualified file path.

Parameters:
  • reload_families ([baseFamily]) – List of tuples representing families requiring their nested families to be re-loaded.

  • directory_path (str) – Fully qualified directory path to which the task files will be written.

  • counter (int, optional) – Task file name suffix, defaults to 0

Returns:

True if file was written successfully, otherwise False.

Return type:

bool

duHast.Revit.Family.Data.family_reload_advanced_utils.delete_old_task_lists(directory_path)

Deletes all overall task files in given directory.

Parameters:

directory_path (str) – Fully qualified directory path containing the task files to be deleted.

Returns:

True if all files got deleted successfully, otherwise False.

Return type:

bool

duHast.Revit.Family.Data.family_reload_advanced_utils.write_out_empty_task_list(directory_path, counter=0)

Writes out an empty task list in case nothing is to be reloaded.

Parameters:
  • directory_path (str) – Fully qualified directory path to which the task files will be written.

  • counter (int, optional) – Task file name suffix, defaults to 0

Returns:

True if file was written successfully, otherwise False.

Return type:

bool

duHast.Revit.Family.Data.family_reload_advanced_utils.read_change_list(file_path)

Reads list of changed families from file into named tuples.

Parameters:

file_path (str) – Fully qualified file path to change list file.

Raises:
  • Exception – “Changed families list files does not exist.”

  • Exception – “Empty families list file!”

Returns:

list of named tuples

Return type:

[changed_family]

duHast.Revit.Family.Data.family_rename_files module

Helper functions to rename family files on a local or network drive.

This helper function expect a folder containing rename directive files. For format of those files refer to module RevitFamilyRenameFilesUtils

Note:

  • The revit category is not used when renaming files but when renaming nested families.

  • Any associated type catalogue files will also be renamed to match the new family name.

  • Rename directives may not have the filePath property set if the directive is only meant to be used on loaded families.

duHast.Revit.Family.Data.family_rename_files.rename_family_files(directory_path, progress_callback=None)

Entry point for this module. Will read rename directives files in given directory and attempt to rename family files and any associated catalogue files accordingly.

Note: for rename directive file structure refer to module family_rename_files_utils

Parameters:

directory_path (str) – Fully qualified directory path to where rename directive files are located.

Returns:

Result class instance.

  • result.status. True if files where renamed successfully, otherwise False.

  • result.message will contain each rename messages in format ‘old name -> new name’.

  • result.result empty list

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.Family.Data.family_rename_find_host_families module

Finds host families of nested families requiring to be renamed.

  • read file rename change list:

  • text file (tab separated) with columns: currentFamilyName currentFamilyFilePath categoryName newFamilyName

  • note: current family file path could be blank in situations where just a rename of a nested family is required…

  • read base data file processing list (created by RevitFamilyBaseDataProcessor module)

  • extract all root families (no :: in root path)

  • extract all nested families ( :: in root path)

  • loop over nested families and find any family where:
    • family at first nesting level is in rename list by name and category

    • extract root family name and add to identified host family list

  • loop over root families

  • find match in identified host families

  • write out root family date: family file path, family name, category

duHast.Revit.Family.Data.family_rename_find_host_families.find_host_families_with_nested_families_requiring_rename(input_directory_path)

Finds all host families in data set containing nested families needing to be renamed.

Parameters:

input_directory_path (str) – Fully qualified directory path containing rename directives and family base data report.

Returns:

Result class instance.

  • result.status: True if any host families are found with nested families needing renaming, otherwise False.

  • result.message: processing steps with time stamps

  • result.result: [rootFamily]

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.Family.Data.family_rename_loaded_families module

Helper functions to rename family loaded families in a project file or family file.

This helper function expect a folder containing rename directive files. For format of those files refer to module family_rename_files_utils.

duHast.Revit.Family.Data.family_rename_loaded_families.rename_loaded_families(doc, directory_path)

Entry point for this module. Will read rename directives files in given directory and attempt to rename loaded families accordingly.

Note: for rename directive file structure refer to module family_rename_files_utils

Parameters:

directory_path (str) – Fully qualified directory path to where rename directive files are located.

Returns:

Result class instance.

  • result.status. True if a single families was renamed successfully, otherwise False.

  • result.message will contain each rename messages in format ‘Renamed family from :’ +current Name + ‘ to ‘ + newName.

  • result.result empty list

On exception:

  • result.status (bool) will be False.

  • result.message will contain an exception message in format: ‘Failed to rename family from :’ + currentName + ‘ to ‘ + newName

  • result.result will be empty

Return type:

Result

duHast.Revit.Family.Data.family_report_data_writer module

Module containing functions to write report files from data previously read from file.

duHast.Revit.Family.Data.family_report_data_writer.get_storage_data(family_data)

Retrieves the storage data as list of strings sorted by storage type.

Parameters:

family_data ([FamilyDataFamily]) – List of family instances.

Returns:

A dictionary where the key is the storage data type, and value is a nested list of lists of strings representing the storage data.

Return type:

{str:[[str]]}

duHast.Revit.Family.Data.family_report_data_writer.get_storage_headers(family_data)

Gets the storage property (report) headers

Parameters:

family_data ([FamilyDataFamily]) – List of family instances.

Returns:

A dictionary where the key is the storage data type, and value is a nested list of lists of strings representing the storage data property names.

Return type:

{str:[[str]]}

duHast.Revit.Family.Data.family_report_data_writer.write_data_from_families_to_files(family_data, directory_path)

Writes family data retrieved from report files back to file.

Parameters:
  • family_data ([FamilyDataFamily]) – List of family instances

  • directory_path (str) – Fully qualified directory path to write report files to.

Raises:
  • TypeError – family_data needs to be a list.

  • TypeError – directory_path needs to be a string.

  • ValueError – Directory: xyz does not exist.

  • ValueError – Failed to get any storage data from family data past in.

Returns:

Result class instance.

  • result.status: Write report files status returned in result.status. False if an exception occurred, otherwise True.

  • result.message: Will contain the fully qualified file path of each of report files written.

  • result.result: Will be a fully qualified file path of each file written.

On exception

  • Reload.status (bool) will be False

  • Reload.message will contain the exception message

Return type:

Result

duHast.Revit.Family.Data.family_report_reader module

Family report data utility module containing functions to read the data from file.

duHast.Revit.Family.Data.family_report_reader.convert_data_rows_to_data_storage(data_rows, target_type)

Convert the data rows into the target type of data storage object.

Parameters:
  • data_rows (list) – The data rows to be converted into the target type of data storage object.

  • target_type (IFamilyDataStorage) – The target type of data storage object to convert the data rows into.

Returns:

A Result object containing the list of IFamilyDataStorage objects if successful.

Return type:

Result

duHast.Revit.Family.Data.family_report_reader.read_data_from_file_into_storage(file_path, data_type)

Read the data from the file and return a list of IFamilyDataStorage objects.

Parameters:
  • file_path (str) – The path to the file to read the data from.

  • data_type (IFamilyDataStorage) – The type of data storage the file data is to be converted to.

Returns:

A Result object containing the list of IFamilyDataStorage objects if successful.

Return type:

Result

duHast.Revit.Family.Data.family_report_reader.read_family_base_data(file_path)

Read the family base data from the file and return a list of FamilyBaseDataStorage objects.

Parameters:

file_path (str) – The path to the file to read the data from.

Returns:

A Result object containing the list of FamilyBaseDataStorage objects if successful.

Return type:

Result

duHast.Revit.Family.Data.family_report_reader.read_family_category_base_data(file_path)

Read the family category data from the file and return a list of FamilyCategoryDataStorage objects as part of a result object

Parameters:

file_path (str) – The path to the file to read the data from.

Returns:

A Result object containing the list of FamilyCategoryDataStorage objects if successful.

Return type:

Result

duHast.Revit.Family.Data.family_report_reader.read_family_line_pattern_base_data(file_path)

Read the family line pattern data from the file and return a list of FamilyLinePatternDataStorage objects as part of a result object

Parameters:

file_path (str) – The path to the file to read the data from.

Returns:

A Result object containing the list of FamilyLinePatternDataStorage objects if successful.

Return type:

Result

duHast.Revit.Family.Data.family_report_reader.read_family_shared_parameter_data(file_path)

Read the family shared parameter data from the file and return a list of FamilySharedParameterDataStorage objects as part of a result object

Parameters:

file_path (str) – The path to the file to read the data from.

Returns:

A Result object containing the list of FamilySharedParameterDataStorage objects if successful.

Return type:

Result

duHast.Revit.Family.Data.family_report_reader.read_family_warnings_data(file_path)

Read the family warnings data from the file and return a list of FamilyWarningsDataStorage objects as part of a result object

Parameters:

file_path (str) – The path to the file to read the data from.

Returns:

A Result object containing the list of FamilyWarningsDataStorage objects if successful.

Return type:

Result

duHast.Revit.Family.Data.family_report_reader.read_data_into_family_containers(path_to_data)

Get all csv files in directory provided and attempts to read them into varies lists of data storage objects:

  • FamilyBaseDataStorage

  • FamilyCategoryDataStorage

  • FamilyLinePatternDataStorage

  • FamilySharedParameterDataStorage

  • FamilyWarningsDataStorage

These are then added to a family container object and returned. The family container object contains all storage instances of a specific root or nested family identified by a unique family name nesting path + family category nesting path

Note: The content of multiple csv files of the same data type will be combined into a single list of objects.

Parameters:

path_to_data – The path to the directory containing the csv files or fully qualified file path to a single data file.

Returns:

A Result object containing the list of Family Containers objects if successful.

Return type:

Result (list of FamilyDataContainer)

duHast.Revit.Family.Data.family_report_reader.read_data_into_families(path_to_data)

Read the data from the csv files in the directory and return a list of FamilyDataFamily objects.

Parameters:

path_to_data (str) – The path to the directory containing the csv files or fully qualified file path to single report csv file.

Returns:

A Result object containing the list of FamilyDataFamily objects if successful.

Return type:

Result (list of FamilyDataFamily)

duHast.Revit.Family.Data.family_report_utils module

Family report data utility module containing functions to manipulate report files.

duHast.Revit.Family.Data.family_report_utils.combine_reports(previous_report_path, new_report_path)

This combines family reports:

  • reading reports into FamilyDataFamily instances

  • comparing the previous report families with the new report families and
    • adding any new families found in the new reports

    • adding previous report families not found in new report families

This function checks at the end whether families still exist on file server. If not, they will be removed from the data set.

Parameters:
  • previous_report_path (str) – A fully qualified file path to the previous report file.

  • new_report_path (str) – A fully qualified file path to the new report file.

Returns:

Result class instance.

  • .status True if successfully combined report(s). Otherwise False.

  • .message will contain count of new families added and previous families retained.

  • . result will contain list of FamilyDataFamily instances representing the combined data set

On exception:

  • result.status (bool) will be False.

  • result.message will contain generic exception message.

  • result.result will be empty

Return type:

Result

duHast.Revit.Family.Data.family_report_utils_deprecated module

Family report data utility module containing functions to read the data from file.

Reads family base data into two list of named tuples.

rootFamily:

  • name

  • category

  • filePath

nestedFamily:

  • name

  • category

  • filePath

  • rootPath [str]

  • categoryPath [str]

class duHast.Revit.Family.Data.family_report_utils_deprecated.rootFamily(name, category, filePath)

Bases: tuple

Create new instance of rootFamily(name, category, filePath)

category

Alias for field number 1

filePath

Alias for field number 2

name

Alias for field number 0

class duHast.Revit.Family.Data.family_report_utils_deprecated.nestedFamily(name, category, filePath, rootPath, categoryPath)

Bases: tuple

Create new instance of nestedFamily(name, category, filePath, rootPath, categoryPath)

category

Alias for field number 1

categoryPath

Alias for field number 4

filePath

Alias for field number 2

name

Alias for field number 0

rootPath

Alias for field number 3

duHast.Revit.Family.Data.family_report_utils_deprecated.combine_reports(previous_report_path, new_report_path)

This combines two reports by:

  • building an aggregate data dictionary of each report (key root family file path, values lists containing the row data read from file for the root family as well as any nested families)

  • comparing the previous report dictionary with the new report dictionary and
    • adding any new families found in the new report dictionary

    • updating any previous report families found with data matching the root family in the new report dictionary

All reports start with the following 2 columns: root rootCategory

First entry (after split at separator) in each of these columns identifies root family uniquely. Assume that new report only ever adds or substitutes entries in previous report but does not delete from it!

This function checks at the end whether families still exist on file server. If not, they will be removed from the data set.

Parameters:
  • previous_report_path (str) – A fully qualified file path to the previous report file.

  • new_report_path (str) – A fully qualified file path to the new report file.

Returns:

list of lists of report rows

Return type:

[[str]]

Module contents