Set New Name to Families of a Category

Hello Everybody!

I’m trying to set a New name to all my family types in the Wall category.

I want my family names to follow this logic :
(Prefix) + (AssemblyCode) + (InstanceLength)

and this new logic will replace the old names

SO for example:
LL-MUR-AA-Brique 90 mm- Material 79
will be:
LL-MUR-PL-90

What I want to do it is

  1. to replace the AssemblyCode with a new code
  2. Set the New Name, and erase the existing ones
    How can I do ?

I tried to , but unfortunately I haven’t had great success.
Can somebody help me?

Hello,

I hope this is what you require.

The last node that I have used is the Element.SetName from Clockwork package.

1 Like

Hello @AmolShah thank you!
It works perfectly!

In the case I want to create an association within more than two elements :
for example I want to do these replacements :

“PL” instead of “AA”
“RO” instead of “CW” (like the precious script), but also)
“DE” instead of “RT”
“RF” instead of “GT”
“ED” instead of “DD”

Is it possible to make these changements at the same time ?
(I guess in that case I cannot use anymore “if” )

I hope somebody knows how to do it!

Thank you in advance !

I tried to do this script, thinking it could work,
but it doesn’t really… :confused:

My goal is to replace, in the type wall names these codes with new ones creating a correspondance within old codes and new codes

maybe a dictionary can help you.
https://primer.dynamobim.org/09_Dictionaries/9_Dictionaries-In-Dynamo.html

1 Like

Hi @Fed17,

The ‘String.ReplaceMultiple’ node from Clockwork would work here. See below:

I have used two different listing options, as for some reason, the way it works from ‘List.Join’ and ‘List Create’ is different. If you look, the “PL” does not change with the ‘List Create’ but does with ‘List.Join’ (index 2, 9, 12, 13). I imagine its due to the way the data is handled.

Always a good idea to try a few variations to be sure i guess :sweat_smile:

Best,

Ben

Thank you @ben.dowling for your answer,
I really appreciate your intervention!

When I tried to use ‘String.ReplaceMultiple’ node, revit just changes the name at four wall type families,
which is quite strange :confused:

Hi @Fed17,

The reason is to do with your “xx” input. You have the same node connected to the ‘str’ and the ‘SearchFor’ ports.

You need to connect your Element Name+ node to a String From Object node. Then connect that to your String.ReplaceMultiple at the ‘str’ port.

Hopefully that resolves it. :+1:

Best,

Ben

Hello @ben.dowling, I tried to follow your advice.
It works, but not the way I want.
In fact, it keeps the family name adding the suffix, and it doesn’t do the substitution with a new name, as I need.

I think the previous script that @AmolShah posted was good for my case. Now I just need to adapt it to a multiple choose (at the place of the boolean which gives a limited choose to two values).

Do somebody know how to do this?

Hi @Fed17,

Sorry to hear it didn’t work. Having had another look at your previous image, you have your nodes set to shortest lacing. Change them back to Auto. That might resolve the issue.

I have rebuilt the set up on my end and works perfectly. See below:

1 Like

Oh :open_mouth:
thank you @ben.dowling, this is very nice from you!

I tried it!
Unfortunately, I have still problems :cry:
The old family name, the whole name, after launching the script, stays there. (see the picture below)
And this is not what I want.

I would like from the formula to rename the family, creating a new family name beginning from zero.
And I would like that Revit forget about the old family name.

How can I solve this problem?

hi @Fed17,

It looks more like your Prefix and Parameter Value are duplicating (or running twice) than the name being retained.

Could you send me the .dyn file?

Of course!!!
This is the file,
it works , but when I launch that, Revit keeps in the project browser the original name instead of substitute it completely.
(It adds the new name to the old name creating a combination of both, that is not exactly what I want)
I hope you can figure it out from my dyn file!

Thank you a LOT in advance!

Set NewName walls_multiple changing code3.dyn (12.9 KB)

Hi @Fed17,

Try this instead

String.Contains(a,“PL”,false)?
“AA”:
String.Contains(a,“RO”,false)?
“CW”:
String.Contains(a,“DE”,false)?
“RT”:
String.Contains(a,“RF”,false)?
“GT”:
String.Contains(a,“ED”,false)?
“DD”:
a;

Solution.dyn (27.6 KB)

2 Likes

Thank you @AmolShah for your precious advice!!

This works perfectly!!
Now I have to solve this problem : there is some elements that have been duplicated.
Revit still accept the duplicated name, but I want to differentiate their name.

SO I would like to set a number at the end ( follow an order 1,2,3)

do for example I would like to do this:

Instead of
FF-MUR-BB-300 (x3)

I will have:

FF-MUR-BB-300
FF-MUR-BB-300-1
FF-MUR-BB-300-2

I can see the duplicate families but I can’t add the increasing number at the end.
Does somebody know how to do it?

Hi @Fed17,
It can surely be done using the group by key and count node.

Solution.dyn (40.2 KB)

HELLO @AmolShah!
I tried to use it and adapt it to my script!
However, it doesn’t return the family name I want :confused:

It create the good new name (I can see it in the last block) but when linked to the block “Element.SetName” it doesn’t work …
do you have any ideas?

(and an other little thing is that it gives the value “1,2” instead of “01,02” but this is secondary )

Thank you in advance

also, what is very strange is that I can have what I want in Dynamo but not in revit Browser.
The image shows that when I invert the order of the links within the nodes in “Element.SetName” (which is basically incorrect I think, though it works ), dynamo create a list with the good values.
However the new names don’t show up in the family name browser…:confused:

You are not getting the result because the levels on your both lists don’t match.

What is the point of using List.Create node for an already generated list?
(I never used it anywhere in my attached graph)

Try removing the List.Create node or add the missing the List.Flatten nodes before the SetName node.

SO I would like to set a number at the end ( follow an order 1,2,3)
do for example I would like to do this:
Instead of
FF-MUR-BB-300 (x3)
I will have:
FF-MUR-BB-300
FF-MUR-BB-300-1
FF-MUR-BB-300-2

It’s giving you 1,2,… because you asked for it earlier.
However, you can get the 01,02,… using the nodes in the blue box.

Also, I highly recommend that you watch/read few tutorials to get better understanding about the nodes and working of Dynamo.

Hello @AmolShah, you’re right the List.Create was not the good choose.
However , when I use List.Flatten, it gives error.
Thank you for your suggestion, I think I need to study more about Dynamo.
I’m trying to do something which is complicated for me, but necessary for the project.
Thanks to yours and the other’s answer I hope I will able to do something that it is not easy for my current level!