Update existing parameters in model

Hi,

I am trying to update existing parameters of type “Shared”.
So want to be able to retrieve these parameters and adjust which categories these have.
I don’t want to create new parameters in the Shared Parameters file, only update the ones in the model.

I’ve tried some custom nodes but can’t get it to work the way I want.

Has anyone had success with what I’m trying to achieve?

You need to show us what you have so far and where you’re specifically running into issues.

Hi @Nick_Boyts

The error is at *collector = FilteredElementCollector(doc).OfClass(Definition)
“not a recognized Revit API type Parameter name: type”

def update_parameter_categories(parameter_name, new_categories):

        t = Transaction(doc, 'History name for undo Transaction')
        t.Start()
        # Find the shared parameter by name
        definition = None
        collector = FilteredElementCollector(doc).OfClass(Definition)
        for param_def in collector:
            if param_def.Name == parameter_name:
                definition = param_def
                break

        if definition:
            # Clear existing categories associated with the shared parameter
            definition.ClearCategories()
            # Update categories associated with the shared parameter
            for new_category in new_categories:
                definition.AddCategory(new_category.Id)
        else:
            print("Shared parameter not found!")
        # Commit the transaction
        t.Commit()




parameter_name = "RKL_Produkt_BSABe"
new_category = Category.GetCategory(doc, BuiltInCategory.OST_Walls)  # Get the desired category

update_parameter_categories(parameter_name, [new_category])

I wouldn’t recommend getting your parameter definition this way, even if it did work as there is a built in property of the document class ParameterBindings.

If you really wanted to use the filtered element collector, you would likely want to look for a SharedParameterElement not a definition.