Sample Code Revit Batch Processor 1.1.11 documentation
get_unique_nested_families_from_path_data()
get_unique_root_families_from_family_data()
get_missing_families()
process_families()
check_families_missing_from_library()
get_direct_root_families()
find_missing_families_direct_host_families()
root_family
nested_family
read_overall_family_data_list()
read_overall_family_data_list_from_directory()
read_overall_family_data_list_into_nested()
read_overall_family_data_list_into_nested_from_directory()
cull_nested_base_data_blocks()
get_nested_family_data_for_root_family()
find_root_families_not_in_nested_data()
find_direct_host_families()
find_all_direct_host_families()
find_root_families_from_hosts()
change_family_category
change_family_sub_category
graphic_property_rgb
graphic_property_line_weight
graphic_property_material
graphic_property_three_d_cut_projection
sub_category_properties_container
sub_category
root_family
nested_family
EXCEPTION_EMPTY_FAMILY_SUBCATEGORY_DATA_FILES
read_overall_family_data_list()
read_overall_family_category_data_from_directory()
read_overall_change_category_directives_list()
read_overall_family_category_change_directives_from_directory()
read_overall_family_sub_category_change_directives_from_directory()
read_overall_change_sub_category_directives_list()
get_families_requiring_sub_category_change()
convert_data_rows_to_data_storage()
read_data_from_file_into_storage()
read_family_base_data()
read_family_category_base_data()
read_family_line_pattern_base_data()
read_family_shared_parameter_data()
read_family_warnings_data()
read_data_into_family_containers()
read_data_into_families()
Filters all generic forms (3D extrusions) in family. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A collector of Autodesk.Revit.DB.GenericForm. :rtype: Autodesk.Revit.DB.FilteredElementCollector
Filters all curve-based elements in a family, including symbolic lines and model lines.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
A list of Autodesk.Revit.DB.CurveElement.
list of Autodesk.Revit.DB.CurveElement
Filters all model text elements in family. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A collector of Autodesk.Revit.DB.ModelText. :rtype: Autodesk.Revit.DB.FilteredElementCollector
Filters all reference planes in family. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A collector of Autodesk.Revit.DB.ReferencePlane. :rtype: Autodesk.Revit.DB.FilteredElementCollector
Create a dictionary of family name and the Family element :param rvt_doc: Revit document :type rvt_doc: Autodesk.Revit.DB.Document :return: Dictionary of family name and Family element :rtype: dict
Returns a bounding box of the family instance based on solids in the family instance geometry only.
doc (Autodesk.Revit.DB.Document) – The revit document.
family_instance (Autodesk.Revit.DB.FamilyInstance) – The family instance to get the bounding box from.
The bounding box of the family instance or None if no solids within the family instance are found.
Autodesk.Revit.DB.BoundingBoxXYZ or None
Places a family instance by level.
Note: It is much faster to modify the family instance after placement in the same transaction than to place it in one transaction and modify its parameters in a separate transaction. Use the modify_action parameter to provide a function that modifies the family instance after placement. Function to accept a family instance as a parameter.
doc (Autodesk.Revit.DB.Document) – The revit document.
location_point (Autodesk.Revit.DB.XYZ) – The location point of the family instance.
family_symbol (Autodesk.Revit.DB.FamilySymbol) – The family symbol to place.
target_placement_level (Autodesk.Revit.DB.Level) – The level to place the family instance on.
transaction_manager (function) – The transaction manager to use.
modify_action (function) – An action to run after the family instance is placed to modify its properties.
A result object.
Places a family instance in a basic wall.
Note: It is much faster to modify the family instance after placement in the same transaction than to place it in one transaction and modify its parameters in a separate transaction. Use the modify_action parameter to provide a function that modifies the family instance after placement. Function to accept a family instance as a parameter.
doc (Autodesk.Revit.DB.Document) – The revit document.
location_point (Autodesk.Revit.DB.XYZ) – The location point of the family instance.
wall (Autodesk.Revit.DB.Wall) – The wall to place the family instance in.
family_symbol (Autodesk.Revit.DB.FamilySymbol) – The family symbol to place.
target_placement_level (Autodesk.Revit.DB.Level) – The level to place the family instance on.
transaction_manager (function) – The transaction manager to use.
modify_action (function) – An action to run after the family instance is placed to modify its properties.
A result object.
Bases: IFamilyLoadOptions
Defines behavior when a family is found in the model.
Overwrite parameter values is set to True.
familyInUse (_type_) – _description_
overwriteParameterValues (_type_) – _description_
True
bool
Defines behavior when a shared family is found in the model.
Overwrite parameter values is set to True. In case of any shared sub components already in the model but different in family loaded, the project version will be used.
sharedFamily (_type_) – _description_
familyInUse (_type_) – _description_
source (_type_) – _description_
overwriteParameterValues (_type_) – _description_
True
bool
Set parameter value based on the storage type of the parameter.
param_w (Parameter) – The parameter to set the value for.
manager (FamilyManager) – The family manager.
value (str) – The value to set the parameter to.
The result of the operation.
res.Result
Set parameter value.
doc (rdb.Document) – The Revit document.
manager (FamilyManager) – The family manager.
fam_para (Parameter) – The parameter to set the value for.
value (str) – The value to set the parameter to.
The result of the operation.
res.Result
Set parameter value as a formula.
doc (rdb.Document) – The Revit document.
manager (FamilyManager) – The family manager.
fam_para (rdb.Parameter) – The parameter to set the formula for.
formula (str) – The formula to set.
The result of the operation.
res.Result
Changes a shared family parameter to a standard family parameter.
Note: will need updating to support ForgeType fro Revit 2022 onwards
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
parameterName (str) – The shared parameter name.
prefix (str, optional) – Revit requires the new parameter to have a different name to the shard parameter, therefore a prefix to the name is applied, defaults to ‘_’
Result class instance.
Parameter change status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the name of the shared parameter and the new family parameter name.
result.status will contain the new family parameter.
On exception (handled by optimizer itself!):
result.status (bool) will be False.
result.message will contain generic exception message.
result.status will be an empty list
Associate a nested family instance parameter ( can be type or instance) with a host family parameter.
doc (Document) – The Revit document.
nested_family_instance (FamilyInstance) – The nested family instance.
target_parameter_name (str) – The target parameter name.
source_parameter_name (str) – The source parameter name.
The result of the operation.
res.Result
Filter the parameters by whether they are determined by a formula or not.
parameters (list) – The list of parameters
keep_if_formulae_driven (bool) – True to keep the parameters that are determined by a formula, False otherwise
The filtered list of parameters
list
This function sets any reference plane with reference type ‘weak’ within a family to reference type ‘not a reference’.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
Result class instance. - result.status (bool): True if at least one reference plane type was successfully changed; otherwise, False. - result.message (str): One row entry per reference plane requiring reference type change. - result.result (not used).
This function sets any model or symbolic curve in a family with reference type ‘weak’ to reference type ‘not a reference’.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
Result class instance. - result.status (bool): True if at least one curve reference type was successfully changed; otherwise, False. - result.message (str): One row entry per curve element requiring reference type change. - result.result (not used).
Reloads a number of families with setting: parameter values overwritten: True
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
library_location (str) – _description_
include_sub_folders (bool) – _description_
UserWarning – _description_
Returns True if any of the reload actions was successful.
bool
Get all loadable family ids in file
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
List of element ids representing loadable families.
list of Autodesk.Revit.DB.ElementId
Returns a list of symbol ids not present prior to reload.
Compares past in list of id’s and returns ids not in preloadSymbolIdList
pre_load_symbol_id_list (list of Autodesk.Revit.DB.ElementId) – List of Ids of symbols prior the reload.
after_load_symbol_list (list of Autodesk.Revit.DB.ElementId) – List of ids of symbols after the reload.
List of element ids representing Family Symbols.
list of Autodesk.Revit.DB.ElementId
Reloads a single family into a Revit document.
Will reload family provided in in path. By default the type parameter values in the project file will be overwritten with type parameter values in family.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
family (Autodesk.Revit.DB.family) – The family to be reloaded
family_file_path (str) – The fully qualified file path of the family to be re-loaded.
None
Result class instance.
Reload status (bool) returned in result.status.
Reload message: contains the reload log messages.
Return family reference stored in result.result property on successful reload only (single entry in list)
On exception
Reload.status (bool) will be False
Reload.message will contain the exception message
These helper function expect a text file in csv format with 4 columns:
Current family name: with out the file extension
File path : fully qualified file path to the family file.
Family category: the Revit category of the family.
New family name: the new family name without the file extension.
Note:
First row is treated as a header row and its content is ignored.
Retrieves file rename directives from a given folder location.
directory_path (str) – Fully qualified folder path to folder containing directives.
Result class instance.
result.status. True if rename directives where found and loaded successfully, otherwise False.
result.message will contain number of directives found in format:’Found rename directives: ‘ + number
result.result list of directives
On exception:
result.status (bool) will be False.
result.message will contain an exception message.
result.result will be empty
Export the family types catalogue file.
doc (rdb.Family) – The family document to extract the type data from.
file_path (str) – The path to save the catalogue file. If None, the file will be saved in the same location as the family with the same name as the family.
Supports 2 methods of data extraction:
from family file on disk
from family element instance in document
Write the data to a temp XML file and read it back.
an_action_to_write_xml_data (function) – The action to write the XML data.
The data read back from the XML file.
XmlDocument or None if an error occurred.
Write the data to an XML file and read it back.
an_action_to_write_xml_data (function) – The action to write the XML data.
xml_file_path (str) – The path of the XML file.
The data read back from the XML file.
XmlDocument or None if an error occurred.
Get the family type data from the family document using the XML extraction method. This can be used to extract the type data from a family document within a Revit session but without opening the family in Revit.
application (Autodesk.Revit.ApplicationServices.Application) – The Revit application object.
family_name (str) – The name of the family.
family_path (str) – The path of the family file.
use_temporary_file (bool) – Whether to use a temporary file for the XML data.
A result object with .result containing a list of family type data objects. (or empty if failed)
Get the family type data from the family element in a REvit document using the XML extraction method.
revit_family (Autodesk.Revit.DB.Family) – The Revit family object.
A result object with .result containing a list of family type data objects. (or empty if failed)
Loads or reloads a single family into a Revit document.
Will load/ reload family provided in in path. By default the parameter values in the project file will be overwritten with parameter values in family.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
family_file_path (str) – The fully qualified file path of the family to be loaded.
transaction_manager (function) – A function wrapping the load family action in a transaction. Default is in_transaction_with_failure_handling. None assumes a transaction is already in progress.
failure_config (FailureHandlingConfig) – The failure handling configuration object. Default is FailureHandlingConfig()
failure_processing_func (function) – The function to process failures. Default is process_failures
None
Result class instance.
Reload status (bool) returned in result.status.
Reload message: contains the reload log messages.
Return family reference stored in result.result property on successful reload only
On exception
Reload.status (bool) will be False
Reload.message will contain the exception message
Filters all family symbols (Revit family types) of given built in categories from the Revit model.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
cats (ICollection :cats sample: cats = List[rdb.BuiltInCategory] ([rdb.BuiltInCategory.OST_Furniture, rdb.BuiltInCategory.OST_Parking])) – ICollection of Autodesk.Revit.DB.BuiltInCategory values.
A collector of Autodesk.Revit.DB.Element matching filter.
Autodesk.Revit.DB.FilteredElementCollector
Filters all family instances of given built in categories from the Revit model.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
cats (ICollection :cats sample: cats = List[rdb.BuiltInCategory] ([rdb.BuiltInCategory.OST_Furniture, rdb.BuiltInCategory.OST_Parking])) – ICollection of Autodesk.Revit.DB.BuiltInCategory values:
A collector of Autodesk.Revit.DB.Element matching filter.
Autodesk.Revit.DB.FilteredElementCollector
Filters all family instances of a single given built in category from the Revit model.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
builtin_cat (Autodesk.Revit.DB.BuiltInCategory) – single revit builtInCategory Enum value.
A collector of Autodesk.Revit.DB.FamilyInstance matching filter.
Autodesk.Revit.DB.FilteredElementCollector
Filters all families in revit model by whether it is not an InPlace family.
Note: slow filter due to use of lambda and cast to list.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
A list of families matching filter.
list Autodesk.Revit.DB.Family
Get all loadable family ids in file.
doc (Autodesk.Revit.DB.Document) – Current family document.
list of family ids
[Autodesk.Revit.DB.ElementId]
Filters all families in revit model by whether it is an InPlace family.
Note: slow filter due to use of lambda and cast to list
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
A list of families matching filter.
list Autodesk.Revit.DB.Family
Returns all family instances in document.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
A collector with all family instances in document.
Autodesk.Revit.DB.Collector
Checks whether any family instance in document is driven by the ‘Label’ property.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
True if at least one instance is driven by label property. Otherwise False
bool
Get all family types belonging to the same family as types past in.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
type_ids (list of Autodesk.Revit.DB.ElementId) –
list of element id’s representing family symbols (family types)
dictionary: where key is the family id as Autodesk.Revit.DB.ElementId value is a list of all symbol(family type) ids as Autodesk.Revit.DB.ElementId belonging to the family
dic {Autodesk.Revit.DB.ElementId: list[Autodesk.Revit.DB.ElementId]}
Filters all family instances of a single given family symbol (type).
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
type_id (Autodesk.Revit.DB.ElementId) – The symbol (type) id
A collector of Autodesk.Revit.DB.FamilyInstance matching filter.
Autodesk.Revit.DB.FilteredElementCollector
Filters family symbol (type) ids off all available in place families of single given built in category.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
fam_built_in_category (Autodesk.Revit.DB.BuiltInCategory) – built in revit category
A list of Element Ids representing the family symbols matching filter.
list Autodesk.Revit.DB.ElementId
Filters family symbols belonging to list of built in categories past in.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
cats (cats = List[rdb.BuiltInCategory] ([rdb.BuiltInCategory.OST_Furniture, rdb.BuiltInCategory.OST_Parking])) – ICollection of Autodesk.Revit.DB.BuiltInCategory values.
A list of Element Ids representing the family symbols matching filter.
list Autodesk.Revit.DB.ElementId
Filters family symbols (types) belonging to hard coded categories lists (catsLoadableThreeD, catsLoadableTags)
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
A list of Element Ids representing the family symbols matching filter.
list of Autodesk.Revit.DB.ElementId
Returns if the family is shared (true) or not (false)
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
family_symbol (Autodesk.Revit.DB.Family) – The family
True if family is shared, otherwise False
bool
Returns if the family is shared (true) or not (false)
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
family_symbol (Autodesk.Revit.DB.FamilySymbol) – The family symbol (type)
True if family is shared, otherwise False
bool
Checks if symbols (types) of a family are in use in a model. Check is done by comparing entries of fam_type_ids with used_type_ids. :param fam_type_ids: list of symbol(type) ids of a family :type fam_type_ids: list Autodesk.Revit.DB.ElementId :param used_type_ids: list of symbol(type) ids in use in a project :type used_type_ids: list Autodesk.Revit.DB.ElementId :return: False if a single symbol id contained in list fam_type_ids has a match in list used_type_ids, otherwise True. :rtype: bool
Filters symbol (type) IDs and family IDs of families.
The returned list of IDs can be either unused family symbols or entire families if none of their symbols are in use. In terms of purging, it’s faster to delete an entire family definition rather than deleting its symbols first and then the definition.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
unused_type_getter (function (doc) -> list of Autodesk.Revit.DB.ElementId) – A function returning IDs of unused symbols (family types) as a list. It requires the current model document as an argument.
A list of Element IDs representing the family symbols and/or family IDs matching the filter.
list of Autodesk.Revit.DB.ElementId
Filters types obtained by passing in the type_id_getter method and, depending on use_type, returns either the used or unused symbols of a family.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
type_id_getter (function (doc, ICollection, bool) -> list of Autodesk.Revit.DB.ElementId) – A function returning IDs of symbols (family types) as a list. It requires the following arguments: - The current model document. - ICollection of built-in categories. - A boolean: exclude shared families.
use_type (int) – 0 for no dependent elements (not used); 1 for has dependent elements (is in use).
A list of Element IDs representing the family symbols matching the filter.
list of Autodesk.Revit.DB.ElementId
Filters unused non shared family (symbols) type ids in model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param exclude_shared_fam: Default is True (exclude any shared families from filter result) :type exclude_shared_fam: bool :return: A list of Element Ids representing the family symbols matching filter. :rtype: list of Autodesk.Revit.DB.ElementId
Filters unused, non shared and in place family (symbols) type ids in model which can be purged from the model. :param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :return: A list of Element Ids representing the family symbols matching filter. :rtype: list of Autodesk.Revit.DB.ElementId