hello all ,
i am trying to do a simple dynamo script to rename all wall types names that contains the word (Metal) to the name (Test). i filtered the family names and got a list with all the family names containg the word metal , but i just cannot rename this filtered list. i dont know what i am doing wrong here.
i would aappreciate any help.Thank you
What’s the output of the String From List node? Is it doing what you expected? What does the error say?
You’re overcomplicating things by filtering and losing the original order. You can go from the type name straight to String.Replace since the node only replaces the value you’re looking for. You can “change” the name of all types, where any type without “Metal” will be unchanged and give you the original name. Otherwise, you need to make sure you filter out the names and the elements to be renamed.
Thank you nick for your reply and help . string from list node is not doing what is expected, the error says function .But i tried your suggestion to go directly from type name to String.Replace . it is working but it replaces only the word metal in the Name. the name is composed of other letters also. i need that if the name contains the word metal then it changes the whole name to (test). not that it replaces only metal with test and keep the other text as it is as you see in the second image below , i dont know how can i do this ? sorry i am beginner in dynamo
You’re expecting it to produce a function? The error in String.Replace is because you’re providing a function instead of a string to search for. You’re getting a function because you haven’t provided all the inputs to String From List. I believe String From List stringifies a whole list, which doesn’t seem to be what you’d want. The names are already strings anyway.
Gotcha. String.Replace will only replace the substring “Metal” with the replacement string, not provide a whole new name. To do that, you need to create a conditional that returns “Test” if the name contains “Metal”. You can do this with an If statement and the String.Contains node.
thank you for your reply , i now used String.Contains node.and i got all the elemets containg the word metal and i want to rename those elements in the list , but i just cant , maybe those are just the names not the elements themselves i dont know
I’d recommend filtering here, otherwise you’re spending time to write the existing name over the current name (and who knows what issues you’ll run into that way).
@sabra.tarek I believe that all wall types in your project will need unique names (i.e. we can’t have two wall types called “Test”, and as such you’ll need to build a unique name rather than just pushing test.
After filtering the wall types not the names with the results of the String.Contains node, you can build a range of strings such as "TEST " + (1..List.Count(wallTypes)); which will put everything in place. From there you can set the wall type names as desired.