I am trying to chop a list of views grouped by their name

a user copied views a couple times and Revit created duplicate views…some are on sheets and some are not. I am trying to chop the view list into the same name (minus the duplicate digit) so I can check which one is on sheet and remove the duplicates

there is not the same amount of views per grouping…but I want to group the like named views…

image

3 Likes

i thought about that but i have some with no number on the end. I am going to try to give the numberless ones a 0…

Or get the substring from the beginning?

Another solution might be to check if the last character in the string is a number or not and organize that way. Would only work assuming none of your original views end in a number already. I typed a quick python script but didn’t have the time/data to do much testing:

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
nameList = IN[0]
newList = []
c = -1

for i in range(len(nameList)):
	if nameList[i][-1].isnumeric() == False:
		newList.append([nameList[i]])
		c+=1
	else:
		newList[c].append(nameList[i])

OUT = newList

A more complicated way I can think of using @john_pierson’s method is using a search if contains after the remove but that would probably be more headaches.

I was getting an error when feeding in an alternate list into the Python node and noticed that you need to sort the list prior to feeding it in…easily fixed with a List.Sort. (It also doesn’t like duplicate values and creates separate lists which would require a bit more Python scripting.)


An alternate graph using just nodes is below. (I know it is a little long but may be a little more robust?)

1 Like

I like it, it is definitely more robust. The advantage of yours is that if the list of views has one that ends in a number but isn’t a copy, it will be in it’s own list, which mine wouldn’t. Mine assumes that there is always the original view without any numbers at the end and that any copy has an original view as well, which may not always be the case.

I don’t know how you feel about python but the filter by boolmask node group could be replaced with a single python node:

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
boolMask = []
for i in IN[0]:
	if i[-1].isnumeric() == True:
		boolMask.append(True)
	else:
		boolMask.append(False)
		
OUT = boolMask

Yes, Python isn’t my strongest skill, just a novice really. It certainly creates a much more elegant solution, instead of having all of those nodes.
The only thing I like the nodes for is that it is a little easier to follow what is happening at each node and pick up any errors.

thanks guys.,…these are awesome and i will test the later! its a common issue when people are copying views into projects