Sample Code Revit Batch Processor 1.1.11 documentation
Returns all shared parameter ids in the model with the exception of parameters which have a binding and are therefore assumed to be used.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
element_ids ([Autodesk.Revit.DB.ElementId]) – optional list of shared parameter element ids
element_ids_list_is_inclusive_filter (bool) – If true and element_ids list has values only those parameters will be purged if possible. If false and element_ids list has values any parameters in the list will not be purged.
A list of all shared parameter ids in the model.
list of Autodesk.Revit.DB.ElementId
Purge shared parameters by delete.
Note: This is a slow(ish) process and can take a few hours to complete depending on the size of the model and the number of shared parameters.
No parameters with a category binding will be deleted. (refer below for more details on this)
Observations:
the shared parameter itself
the binding (type or instance) to a category
the shared parameter itself
the families (and any of its instances placed) the shared parameter is used in
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
progress_callback (callable) – Callback to report progress.
debug (bool) – Debug mode.
element_ids ([Autodesk.Revit.DB.ElementId]) – optional list of shared parameter element ids
element_ids_list_is_inclusive_filter (bool) – If true and element_ids list has values only those parameters will be purged if possible. If false and element_ids list has values any parameters in the list will not be purged.
Result class instance.
.status True if unused shared parameters where deleted or nothing needed to be deleted. Otherwise False.
.message will contain deletion status.
based on building coder article: https://thebuildingcoder.typepad.com/blog/2012/04/adding-a-category-to-a-shared-parameter-binding.html
Loads a shared parameter file.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
path (str) – (Optional) Fully qualified file path to shared parameter text file.
The opened shared parameter file.
Autodesk.Revit.DB.DefinitionFile
Binds a shared parameter to a revit category.
Refer building coder article referenced in header
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
category (Autodesk.Revit.DB.BuiltInCategory) – The built in category, to which the parameter will be bound.
parameter_name (str) – The parameter name.
group_name (str) – The group under which the parameter appears in shared parameter text file.
paramType (Autodesk.Revit.DB.ParameterType) – The parameter type. (Area, vs text vs… (deprecated in Revit 2022!)
is_visible (bool) – Is parameter visible in UI to users.
is_instance (bool) – True parameter is an instance parameter, otherwise type parameter.
parameter_grouping (str) – Where parameter appears in properties section in UI.
shared_parameter_filepath (str) – Fully qualified file path to shared parameter text file.
Result class instance.
Parameter binding status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the name of the shared parameter.
On exception (handled by optimizer itself!):
result.status (bool) will be False.
result.message will contain exception message.
Adds a shared parameter definition to a family document.
para (tuple (refer module RevitSharedParametersTuple)) – Tuple containing parameter info
mgr (Autodesk.Revit.DB.FamilyManager) – The family manager object
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
def_file (_type_) – The shared parameter definition file.
Result class instance.
True if added successfully. False if an exception occurred.
result.message will contain the name of the shared parameter.
.result.result will contain the family parameter object.
On exception (handled by optimizer itself!):
result.status (bool) will be False.
result.message will contain exception message.
Takes a list of shared parameter definitions and creates a binding to a new category. Will add category to an existing binding if one exists already :param rvt_doc: Revit document :type rvt_doc: Autodesk.Revit.DB.Document :param target_params: List of shared parameter definitions :type target_params: list[Autodesk.Revit.DB.ExternalDefinition] :param target_cat: Category to bind to :type target_cat: BuiltInCategory :param target_param_grp: Parameter Group new parameters will appear in :type target_param_grp: BuiltInParameterGroup :param type_binding: True if type binding, False if instance binding :type type_binding: bool :return: List of successful bindings, list of errors :rtype: tuple
The swap is done by: - changing current shared parameter to a family parameter (dummy) - deleting the old shared parameter definition - swapping the family parameter (dummy) to the new shared parameter.
Note: storage types of old and new shared parameter need to be identical.
Parameter change directives are read from a .csv file:
header row: yes
column 1: current shared parameter name
column 2: new shared parameter name
column 3: fully qualified file path of shared parameter file
column 4: Is parameter instance (True / False)
column 5: parameter grouping name ( refer to module: RevitParameterGrouping)
alias of parameterSettingsData
Swaps out a shared parameter for another. (refer to module header for details)
doc (Autodesk.Revit.DB.Document) – Current Revit family document.
change_directive_file_path (str) – Fully qualified file path to shared parameter change directive.
Result class instance.
False if an exception occurred, otherwise True.
result.message will contain the names of the changed shared parameter(s).
result status will contain lists of new shared parameters
On exception (handled by optimizer itself!):
result.status (bool) will be False.
result.message will contain exception message.
Changes a shared family parameter to a standard family parameter.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
parameter_name (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
Changes a family parameter to a shared parameter.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
parameter_name (str) – The family parameter name.
parameter_data (RevitSharedParametersTuple.parameterData) – A named tup[le containing the shared parameter information
parameter_def (Autodesk.Revit.DB.ExternalDefinition) – The external definition of the shared parameter.
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 family parameter and the new shared parameter name. - result.status will contain the new shared 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
Gets all shared parameters in a model
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
A filtered element collector containing shared parameter elements
Autodesk.Revit.DB.FilteredElementCollector
Gets all the shared parameter definitions from a shared parameter file. Can either be set manually or will be loaded from the default location which Revit is pointing at :param rvt_doc: Current Revit model document. :type rvt_doc: Autodesk.Revit.DB.Document :param shared_param_file_path: (Optional) The path to the shared parameter file. :type shared_param_file_path: str :return: A flat list of shared parameter definitions :rtype: list
Gets all family parameters which are shared parameters.
doc (Autodesk.Revit.DB.Document) – Current Revit family document.
Exception – “Document is not a family document.” when a non family document is past in.
A list of family parameters
[Autodesk.Revit.DB.FamilyParameter]
Gets all family parameters.
doc (Autodesk.Revit.DB.Document) – Current Revit family document.
Exception – “Document is not a family document.” when a non family document is past in.
A list of family parameters
[Autodesk.Revit.DB.FamilyParameter]
Only parameter in both will be returned.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
parameter_gui_ds (list str) – list of shared parameter GUIDs as string values
list of shared parameter GUIDs as string values
list str
Checks, by name, whether a shared parameter exists as a family parameter in a family.
param doc: Current Revit family document. :type doc: Autodesk.Revit.DB.Document :param parameter_name: The name of the parameter. :type parameter_name: str
A family parameter if match was found, otherwise None
Autodesk.Revit.DB.FamilyParameter
Tests if a shared parameter GUID is used by a family parameter.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
shared_para (Autodesk.Revit.DB.SharedParameterElement) – A shared parameter
True is match is found, otherwise False
bool
Returns all unused shard parameter definitions in a family document.
Note: These shared parameters might be used in any nested family!
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
A list of shared parameters
[Autodesk.Revit.DB.SharedParameterElement]
Returns a shared parameter definition from a shared parameter file.
parameter_name (str) – The shared parameter name.
def_file (Autodesk.Revit.DB.DefinitionFile) – The shared parameter file definition.
The shared parameter definition. None if no parameter with a matching name was found.
Autodesk.Revit.DB.ExternalDefinition
Gets all parameter bindings for a given parameter depending on revit version.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
param_name (str) – The name of the parameter.
param_type (Autodesk.Revit.DB.ParameterType) – The parameter type. (Area, vs text vs… (deprecated in Revit 2022!)
List of categories a parameter is attached to.
list of str
Gets all parameter bindings for a given parameter fro Revit versions up to 2022.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
param_name (str) – The name of the parameter.
param_type (Autodesk.Revit.DB.ParameterType) – The parameter type. (Area, vs text vs… (deprecated in Revit 2022!)
List of categories a parameter is attached to.
list of str
Gets all parameter bindings for a given parameter for Revit 2023 onwards
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
param_name (str) – The name of the parameter.
type_id (Autodesk.Revit.DB.ForgeTypeId) – Forge type id
List of categories a parameter is attached to.
list of str
Deletes a single shared parameter based on a name provided.
param doc: Current Revit model document. :type doc: Autodesk.Revit.DB.Document :param shared_parameter_name: The name of the shared parameter. :type shared_parameter_name: str :return: Result class instance.
Parameter delete status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the name of the shared parameter.
result.status will be an empty list.
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
Deletes a single shared parameter based on a guid provided.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
guid (str) – A shared parameter GUID as string.
Result class instance.
Parameter delete status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the name of the shared parameter.
result.status will be an empty list.
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
Deletes shared parameters by GUID from document.
doc (Autodesk.Revit.DB.Document) – Current Revit model document.
parameter_gui_ds (list str) – List of shared parameter GUIDs as string.
Result class instance.
Parameter deletion status returned in result.status. False if an exception occurred, otherwise True.
result.message will contain the name of the shared parameter deleted.
On exception (handled by optimizer itself!):
result.status (bool) will be False.
result.message will contain generic exception message.
alias of parameterData