String.ToTitle

Hi @Kulkul, @JamesP,

Reviving this thread because String.ToTitle is no longer included in the latest version of Rhythm with Dynamo 2.0.2. Seems like @60secondrevit is planning to re-release this node, but not sure when exactly.

Are there any workarounds available? I’ve tried creating my own script for changing all text to Title Case using a python node with “OUT = IN[0].capitalize()” but it seems to only work when I split the list into individual items. This would require manually connecting hundreds of list items which is counterproductive.


2.0.2_Change_Text_Case_WORKING.dyn (35.0 KB)

Hi @James45

This should work for you:

OUT = map(str.title, IN[0])

In future please start new thread, we can’t have multiple solutions in one topic. Cheers!

4 Likes

Thank you for the quick response and solution!

Is there a way to change the second letter after an integer to lowercase?

For example, “1St Floor Plan”, “2Nd Floor Plan” to “1st Floor Plan”, “2nd Floor Plan”.

Solved the previous issue using “String.Replace” by manually changing 2Nd to 2nd. Open to other suggestions, but this seems to work.

Thanks again for the help @Kulkul!

This should work if you still want it:

for string in a:
  ind = -2
  newstring = ""
  for i, char in enumerate(string):
    try:
      if isinstance(int(char),int):
        ind = i
        newstring += char
    except ValueError:
      if i == ind + 1:
        newstring += char.lower()
      else:
        newstring += char
  b.append(newstring)

Example:

1 Like

Hi @James45

If it’s the 2nd word then you can do this in one line of python:

OUT = [i[0] + i[1].lower() + i[2:] for i in map(str.title,IN[0])]

5 Likes

Thanks for this.