Title Image
Parameter Organizer Dynamo Script
Parameter Organizer Dynamo Script

This Dynamo script organizes parameters for the selected elements in Revit. It groups the parameters based on their parameter group and sorts them alphabetically within each group. The script helps streamline the parameter editing process and improves data management by organizing parameters in a more structured and organized manner.

# Dynamo Build Version: 2.10.0
# Revit Version: 2022

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

# Get the active Revit document
doc = DocumentManager.Instance.CurrentDBDocument

# Define a function to organize parameters
def organize_parameters(element):
    if isinstance(element, list):
        elements = element
    else:
        elements = [element]

    # Iterate through each element
    for elem in elements:
        if not isinstance(elem, Revit.Elements.Element):
            elem = elem.ToDSType(True)

        if isinstance(elem, Revit.Elements.FamilyInstance):
            fam_inst = elem.InternalElement
            params = fam_inst.Parameters
        elif isinstance(elem, Revit.Elements.FamilySymbol):
            fam_symbol = elem.InternalElement
            params = fam_symbol.Parameters
        else:
            params = elem.Parameters

        # Group parameters by parameter group
        param_groups = {}
        for param in params:
            group_name = param.Definition.ParameterGroup.Name
            if group_name not in param_groups:
                param_groups[group_name] = []
            param_groups[group_name].append(param)

        # Sort parameters within each group
        for group_name, param_list in param_groups.items():
            sorted_params = sorted(param_list, key=lambda x: x.Definition.Name)
            for i, param in enumerate(sorted_params):
                param.SetOrder(i)

# Get selected elements in Revit
selected_elements = [x.InternalElement for x in IN[0]]

# Organize parameters for the selected elements
organize_parameters(selected_elements)

# Output the organized elements
OUT = selected_elements

Parameter Organizer Dynamo Script:

  1. Launch Autodesk Revit: Open Autodesk Revit and open the project file you want to work with.
  2. Launch Dynamo: In the Revit toolbar, click on the “Dynamo” button to launch the Dynamo visual programming environment.
  3. Create a new Dynamo script: In Dynamo, click on “New” to create a new script.
  4. Check the Dynamo Build Version and Revit Version: At the beginning of the provided Dynamo script, you will find the specified Dynamo Build Version and Revit Version.
  5. Add input nodes: In the Dynamo workspace, add the following input nodes by searching for them in the search bar and dragging them onto the canvas:
    • Element (List of Elements): Represents the elements you want to organize the parameters for.
  6. Add the Python script: Add a “Python Script” node to the canvas by searching for it in the search bar and dragging it onto the canvas. Connect the input nodes to the corresponding inputs of the Python script node.
  7. Copy and paste the provided Dynamo script: Replace the default code in the Python script node with the provided Dynamo script mentioned at the beginning of this response.
  8. Run the Dynamo script: Click on the “Run” button in Dynamo to execute the script.
  9. Check the results: The script will organize the parameters of the selected elements by grouping them based on parameter group and sorting them within each group. You can review the elements in Revit to see the organized parameters.

To use the script, select the elements you want to organize parameters for and connect them to the “Element” input in Dynamo. The organized elements will be outputted from the “OUTnode.

Please note that this script assumes you have the required packages (RevitAPI and RevitNodes) installed in Dynamo. Make sure to load the necessary packages before running the script.

We will inform you when the product arrives in stock. Please leave your valid email address below.
Shopping cart0
There are no products in the cart!
0
Select an available coupon below