Open to ideas here, I have a host of family types to rename to comply with a new naming convention. Tried element.name = x in a family document, it says the parameter is read only.
Tried it as well as element.setname in a Revit doc, it changed the name in the browser, but not the actual type name. When closing and reopening the file, names reverted.
Tried duplicating the family type and giving it the new name, it didn’t work.
RenameTypes.dyn (17.4 KB)
What element are you trying to change the name from? The type name is a property of the type itself so you won’t be able to change it at the instance level. Make sure you’re changing it from the FamilyType
element.
There are more than a handful of similar topics that address this. Have you looked through them and confirmed you’re not missing anything?
yeah so I am using Family Types, I pulled them with a filtered element collector WhereElementIsElementType - looking through some archives, I am not finding an exact replica of my situation tbh
Is this specific to some Revit version? In using Revit 2022 for this operation.
I tried the node OOTB and it wasn’t working for me. I didnt really need a search and replace as I had already created a clean list of types, old type names, and new type names myself, so I grabbed the code from the node and tweaked it to my liking. It seems that the function FamilyMan.RenameCurrentType doesnt work. As you see in my screen shot, I am sending to OUT my renamed types, then my types and type.name. It is not making any changes in the family.
This is similar to what I observed in the RVT environment, the name within the browser would change, but not the type name. Its very odd.
It would be helpful if you showed us the inputs you’re using. We can’t give you contextually accurate suggestions if you don’t share the context.
You’re missing a few steps in your python code for the method you’re using. RenameCurrentType()
obviously renames the current type. You’re not doing anything to set the current type for each type you want to rename. So right now your code would be renaming the current type in the family editor for each name you’ve provided. You also return the type.Name before you’ve committed the transaction, so the type wouldn’t actually have the new name yet. Of course neither of these issues explain why it’s not at least working for the one type though. Are you in a family document? This is where we need more information.
This method works for me in 2024 and 2.19.
I am doing this in a family document. It seems that perhaps the node and or function is only capable of handling one search and replace at a time maybe? I am sending it multiple search strings, multiple new names, and multiple Revit Family Types in an RFA document. all lists are the same length, essentially old name (string), new name (string), Type (FamilyType)
Anyway, Im kinda over thinking because I remembered that the DiRoots family manager can also automate this for me, so I will probably just use that, even tho its a bit more manual. Thanks!
As I mentioned in my previous response, that’s not how that method works, since it specifically changes the current type. You’re not doing any searching for existing names and you’re not iterating through the types you provide. You would need to change types in the family manager for that method to work.
Changing type (or family) names can be really finicky. If you have a stable solution like DiRoots, it’s probably the best option, even if it requires a little more manual involvement.
1 Like
ah gotcha, yeah that makes sense. so I would need to add a line to my loop to iterate through the types in the list. what does that function look like?
The CurrentType
property is a get/set property, so you can set it equal to the type and it will change the current type in the family document. The trick here is that you need to do that within a transaction to have it actually go through and allow you to change the type name.
CurrentType Property (revitapidocs.com)