Loading Shared Parameters From Excel - Revit 2024

I’m having trouble using an excel file to take the name of shared parameters in it, with their settings; and load it into the project. I’m using some Python 3 code here:

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

# Function to add shared parameters
def add_shared_parameters(param_data, shared_params):
    app = doc.Application
    shared_params_file = app.OpenSharedParameterFile()
    if shared_params_file is None:
        raise Exception("Shared parameters file not found.")
    
    for i, param in enumerate(param_data):
        try:
            param_group = param{0]
            param_type = param[1]
            param_group = param[2]
            bip_name = param[3]
            is_instance = param[4]
            param_name = param[5]
            
            # Find the shared parameter in the shared parameters file
            for group in shared_params_file.Groups:
                if group.Name == param_group:
                    for definition in group.Definitions:
                        if definition.Name == param_name:
                            # Create the shared parameter
                            TransactionManager.Instance.EnsureInTransaction(doc)
                            new_param = doc.FamilyManager.AddParameter(definition, BuiltInParameterGroup.PG_DATA, is_instance)
                            TransactionManager.Instance.TransactionTaskDone()
                            break
        except IndexError:
            print(f"IndexError: Check the data at index {i} in param_data or shared_params.")

# Example usage
param_data = IN[5]  # Connect the Excel data to this input
shared_params = IN[6]  # Connect the filtered shared parameters to this input

# Ensure that the length of param_data and shared_params are consistent
if len(param_data) != len(shared_params):
    raise Exception("The length of param_data and shared_params must be the same.")

add_shared_parameters(param_data, shared_params)

And the sample excel list is formatted as so:

Column 1 Column 2 Column 3 Column 4 E F
Shared Parameter Name Shared Parameter Group Parameter Type Parameter Group BIP Name Instance

What’s the error on the Boolean mask filter? Right now it is giving you an error. Note before that you are getting an item at index 0.0000. An index is an integer. Not a float. I don’t think the data coming out of that mode is giving you a bool. Which is probably where the next node is failing.

Dynamo will actually round a double or float to an indexing integer automatically. I think the issue is that you’re just fundamentally using FilterByBoolMask wrong. You don’t have a list to filter and you don’t have booleans to create the mask. You’re reading the SPF as a string. If you want to filter it in any way then you’ll have to modify and transform it into a list structure. You’ll also need to create a conditional for your boolean mask - likely with String.Contains or == if you’re looking for matches.