Rename and sort types by name?

Hi,

I’m just learning Dynamo and the first practical script I want to create is something that can rename and sort elements(doors, windows, walls etc) by type name.

Background: We almost always name our types by size and assign letters to types with equal size, so two 1000mm doors in a project would be D10a and D10b. During a project, as more and more disciplines add their requirements on different elements these types tend to get scrambled, a lot.

The way I want to solve this is exporting a bunch of parameters to Excel, sort them, import back to Revit and overwrite existing parameters. I’ve created two scripts for this, only trouble is, when I run the import script I get the following error: “Warning: Element.SetParameterByName operation failed.
The parameter is read-only.”. I’ve narrowed this down to the Type Name parameter. So, basically, how do I write text to that parameter?

Hey there,

I guess you are tying to set Type parameters.

In this case you need to get a list of types from your elements and then use Element.SetParameterByName on these types.

Used Element.SetName from Clockwork, worked :slight_smile:

I have another issue with this though. All of the parameters I want to change are type, however the list I get is instance. Still works as long as I change all of the instances to the same value, but can I somehow group all instances of the same type in the list to make a more compact excel file?

Use Element.ElementType to get the family of an instance

Still instance? Or did I misunderstand?

Ok, my bad
Add List.UniqueItems

Brilliant! My last question is the warning I get when I run the script to import the parameters back. Everything works fine as far as I can tell but both last nodes return: “Warning: Element.SetParameterByName operation failed.
The call is ambiguous between the following methods or properties: ‘Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(Autodesk.Revit.DB.Parameter, Revit.Elements.Element)’ and ‘Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(Autodesk.Revit.DB.Parameter, string)’”

Is there a blanc value in your excel?

Yes. There are null values where I have yet to fill in all of the parameters. Is it unsafe to push blank cells?

No, it’s not unsafe, its just that your script won’t run because of it :slight_smile:
Mind you, there may be other problems aswell, but fix this first and i’ll try to help you to the next step (if required)

Actually the script runs and the parameters change. Thing is some of these cells will always be empty, for example one of the parameters are Fire Rating and in any given project not all doors are fire rated. As long as I’m sure that’s what’s giving me a warning it’s fine.

Just tried adding a dash to all empty cells and the script ran without warnings :slight_smile:

Also you can use “Manage.ReplaceNulls”

Excel

Great, thank you!