Refining list by values in it

I’ll do my best to explain… If there is a single value in the list then keep it. If there is more then one value in the list, it needs to be refined by the other values in the list down to one value.

so, Below list 0 has two values. Need to get this to a single value. List 7 has W1.1 as a single value so W1.1 should be removed from list 0

List 10 has four values. W0.5, W0.7 and W0,8 can be found as single values in the list so should be removed and only left with W0,6.

Ending up with a list of single unique values.
image
image

Can this be done or is it to complicated? :confused: Please let me know if this dosn’t make sense and I will try explain better. Hoping theres some sort of workflow to deal with with this if it varies. Something with cross lacing might actually work

Definitely possible but most likely best done using Python or Designscript. Use an if statement to check if each list has more than one item (List.Count > 1 in Designscript or len(list) > 1 in python). If true, check each list containing 1 item and if this item is in your list with more than 1 item, remove it from that list. For example, given a list of lists [[A], [B], [B, C]] the list [B, C] would trigger the first condition, then [A] and [B] would be checked against [B, C]. Nothing would happen with list [A], but list [B] would cause the matching item to be removed from list [B, C].

1 Like

small steps haha. I think this is the beginning of what your saying but im not sure where to go

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.
xs = IN[0]

newlist = []
for x in xs:
	ys = [z[0] for z in xs if len(z) == 1]
	if len(x) > 1:
		for xx in x:
			if xx not in ys:
				newlist.append([xx])
	else:
		newlist.append(x)
		

#Assign your output to the OUT variable.
OUT = newlist
3 Likes

amazing! thank you!