Change View Template Names and Scales

Hi all,
I am getting stuck with the String.Replace Node and not really sure why.
I am trying to use Dynamo to convert an Imperial Template to a Metric one.
There are some name in the View Template I would like to change, for example : Architectural Plan_1/4" to be Architectural Plan_1/50. At the same time, I also want to round up the Scale from 48 to 50.

I am pull out the view templates using Archilab packages, then use String.Replace to replace 1/4" to 1/50 then use Element.Setname from Clockworks, but somehow it did not work.
Also not sure how to change the scale to match the View Template ?

Help please !

Thanks.
Ngoc

Hi @nnguyen,
Welcome to the Dynamo Community.

Try using String.ReplaceMultiple from Clockwork package

Thanks Amol. I did tried it before. Did not work. What version of Dynamo/ Clockworks you are using ?
I am on dynamo 2.0.3 and Clockwork 2.3

I’m using the same versions as well.
image

If that didn’t work, try this Python approach:

def toList(item):
	if isinstance(item, list):
		return item
	else:
		return [item]
		
out = []

strings = toList(IN[0])
searchList = toList(IN[1])
replaceList = toList(IN[2])

if len(searchList) == len(replaceList):
	for string in strings:
		flag = True
		for search,replace in zip(searchList,replaceList):
			if search in string:
				newString = string.replace(search,replace)
				flag = False
				out.append(newString)
				break
		if flag:
			out.append(string)
else:
	out = "Search & Replace List lengths don't match"

OUT = out

1 Like

Thanks Amol. I was back from vacation. Will take a look the Python and let you know. Cheers mate.

1 Like

hey Amol thanks for your help. I tried the Phython too. Turned out the input with String doesnt work, I have to use Code Block node. A bit weird. Any way it working now.

1 Like

Also got the scale update as well…Thanks Dynamo community. Saving time is about 3 hours each new project we convert from imperial to metric.