Sample Code Revit Batch Processor 1.1.16 documentation
Updates the type catalogue file for a family document by removing types that are not in the maintain list.
doc (Autodesk.Revit.DB.Document
) – The family document to process.
maintain_types_list (list of nested lists, each containing two strings: [family_name, type_name]) – A list of types to maintain, where each entry is a tuple (family_name, type_name).
Result object containing the status and messages.
Creates a default family type in the family document if a catalogue file is in use…
doc (Autodesk.Revit.DB.Document
) – The family document to process.
Result object containing the status and messages.
Delete non-conforming types in a family document based on a list of types to maintain.
Note
Types reported might only live in a type catalogue file. In that case the family may only contain a place holder type with name “Refer To Catalog File” or similar.
doc (Autodesk.Revit.DB.Document
) – The family document to process.
maintain_types_list (list of nested lists, each containing two strings: [family_name, type_name]) – A list of types to maintain, where each entry is a tuple (family_name, type_name).
Result object containing the status and messages.
Verify that the copy directives are unique based on their new names.
copy_directives (list[FamilyDirectiveCopy
]) – A list of copy directives to verify.
True if all copy directives are unique, False otherwise.
bool
Check the copy directives for duplicates and missing group codes.
:param output_path: The path where the output files will be written.
:type output_path: str
:param copy_directives: A list of copy directives to check.
:type copy_directives: list[FamilyDirectiveCopy
]
:param families_with__missing_group_codes: A list of families with missing group codes.
:type families_with__missing_group_codes: list[FamilyTypeDataStorageManager
]
A Result object containing the status and messages of the checks.
Get unique group codes from the family storage data.
will return a dictioanry where key is the full code and value is the group code without any sub codes. ITSE-002.01 will return {‘ITSE-002.01’: ‘ITSE-002’} ITSE-001 will return {‘ITSE-001’: ‘ITSE-001’}
family_storage_data (FamilyTypeDataStorageManager
) – The family storage data from which to get the unique group codes.
A dictionary of unique codes and their cleaned versions.
{str:str}
Create a copy directive for the catalogue file.
name (str) – The name of the catalogue file.
category (str) – The category of the family.
source_file_path (str) – The path to the source catalogue file.
target_directory (str) – The directory where the catalogue file will be copied to.
new_name (str) – The new name for the catalogue file.
A copy directive for the catalogue file.
FamilyDirectiveCopy
or None if the source file does not exist.
Create copy directives for each unique group code in the family storage data.
family_storage_data (FamilyTypeDataStorageManager
) – The family storage data from which to create copy directives. (takes the family name, category and file path from this data)
unique_group_codes (dictionary {str:str}) – A dictionary where key is the full code and value is the group code without any sub codes.
output_directory (str) – The directory where the copied families will be saved.
code_to_descriptor_map (dict[str, (str, str)]) – A mapping of grouping codes to their descriptions.
A list of copy directives.
list[FamilyDirectiveCopy
]
Create lists of family types to be maintained in the new family based on unique group codes.
family_storage_data (FamilyTypeDataStorageManager
) – The family storage data from which to create type maintained lists.
unique_group_codes (dictionary {str:str}) – A dictionary where key is the full code and value is the group code without any sub codes.
copy_directives (list[FamilyDirectiveCopy
]) – A list of copy directives to be used for creating type maintained lists.
code_to_descriptor_map (dict[str, (str, str)]) – A mapping of grouping codes to their descriptions.
A list of nested type maintained lists with two entries each: new family name, family type name to be maintained. ( a family with multiple times to be maintained will have multiple entries in the list )
list[ list[str] ]
Create swap directives for each unique group code in the family storage data.
family_storage_data (FamilyTypeDataStorageManager
) – The family storage data from which to create swap directives.
unique_group_codes (list[str]) – A list of unique group codes to create swap directives for.
copy_directives (list[FamilyDirectiveCopy
]) – A list of copy directives to be used for creating swap directives.
code_to_descriptor_map (dict[str, (str, str)]) – A mapping of grouping codes to their descriptions.
A list of swap directives.
list[FamilyDirectiveSwap
]
Create directives based on family storage data.
family_storage_data (a list of FamilyTypeDataStorageManager
) – The family storage data from which to create directives.
Result class instance.
result.status: Directive creation status will be returned in result.status. False if an exception occurred, otherwise True.
result.message will be a log of conversion steps.
A list of FamilyDirectiveCopy
directives for copying families.
A list of lists containing family type names to be maintained in the new family.
A list of FamilyDirectiveSwap
directives for swapping family instances of types.
A list of family storage instances that had missing group codes in the code description mapping.
On exception
Reload.status (bool) will be False
Reload.message will contain the exception message
Reload.result will be an empty list
Executes the copy directives for library families.
copy_directives (list) – List of copy directives to execute.
Result object containing the status and messages.
Writes a list of maintain directives to a specified file.
maintain_file_list (list) – List of maintain directives to write.
output_directory (str) – Directory where the file will be written.
Result object indicating success or failure.
Writes swap directives to a specified file.
swap_directives (list) – List of swap directives to write.
output_directory (str) – Directory where the file will be written.
Result object indicating success or failure.
Writes copy directives to a specified file.
copy_directives – List of copy directives to write.
output_directory (str) – Directory where the file will be written.
Result object indicating success or failure.
Writes duplicate directives to a specified file.
copy_directives (list) – List of duplicate directives to write.
output_directory (str) – Directory where the file will be written.
Result object indicating success or failure.
Writes directives to a specified file.
Result object indicating success or failure.
Writes a list of families with missing group codes to a specified file.
family_instances ([FamilyTypeDataStorage]) – List of family instances with missing group codes.
output_directory (str) – Directory where the file will be written.
Result object indicating success or failure.
Cleans up the family name by removing any dashes and spaces, replacing them with underscores.
fam_name (str) – The family name to clean up.
The cleaned up family name.
str
Builds a family name from the given description by cleaning it up.
Description is in format
MAJOR CATEGORY: description part, description part, description part
description (str) – The description to build the family name from.
The cleaned up family name.
str
Loads families to be swapped into the document.
doc (Autodesk.Revit.DB.Document) – The Revit document.
swap_directives (list of dict) – The swap directives containing family names and paths.
List of loaded family symbols.
list of Autodesk.Revit.DB.FamilySymbol
Loads families required for swapping into the document.
doc (Autodesk.Revit.DB.Document) – The Revit document.
swap_directives (list of dict) – The swap directives containing family names and paths.
List of loaded family symbols.
list of Autodesk.Revit.DB.FamilySymbol
Cleans the grouping code by removing any sub codes after a dot.
Converts the grouping code to a file name safe format.
Loads the grouping code and description from a CSV file.
file_path – The path to the CSV file containing the grouping codes and descriptions.
A dictionary mapping cleaned grouping codes to their descriptions.