RhythmForDynamo icon indicating copy to clipboard operation
RhythmForDynamo copied to clipboard

Add support for multiple strings in "elementFilter"

Open j-meds opened this issue 3 years ago • 11 comments

Summary also needs updating as it says it supports "fuzzy searching". For example passing in a list or comma delimited string.

/// <summary>
/// Provides element filtering options by name. For the filter method, we are using something called "LevenshteinDistance". 
/// This was introduced to me here, http://dynamobim.org/fuzzy-string-matching/.
/// </summary>

j-meds avatar Jul 20 '22 13:07 j-meds

The node itself does not do fuzzy searching. That is just how I find the filter method:

So if a user types in StratsWith, I can use Fuzzy Search to find the closest match which would be StartsWith

johnpierson avatar Jul 20 '22 18:07 johnpierson

@johnpierson Possible to support multiple strings in the value ? For example I need to get elements that contain "Door" and "Window".

j-meds avatar Jul 20 '22 20:07 j-meds

That might be possible. I will have to take a look when I have a chance.

johnpierson avatar Jul 20 '22 20:07 johnpierson

@johnpierson Okay please do let me know, if you don't have enough time I can create a PR for it as well. I believe the changes would be in this file ? https://github.com/johnpierson/RhythmForDynamo/blob/master/src/Rhythm/Revit/ElementFilter/ElementFilter.cs

j-meds avatar Jul 20 '22 20:07 j-meds

Yep! That is where the change would be. The biggest thing to consider (and probably the majority of the time) would be for it to work with all list structures.


That being said, it is already doable with list management. (Also if you are looking to filter by category, then the ElementFilter.ByName node is not the correct one to use. But if those values were in the name. then cool) image

johnpierson avatar Jul 20 '22 20:07 johnpierson

@johnpierson Doesn't seem to work in my case. It just fetches back one "Door Schedule"

image

When I use the regular string it works perfectly. Could it be a bug?

image

j-meds avatar Jul 20 '22 20:07 j-meds

updated images

j-meds avatar Jul 20 '22 20:07 j-meds

What does the list structure that you are putting in the elements input look like? That can cause hiccups if it is nested.

johnpierson avatar Jul 20 '22 20:07 johnpierson

@johnpierson I'm opening 3 files and fetching their schedules. I get a list of 3 element list, image

I don't want to flatten because I need to keep separate, it's odd it works fine with the string.

j-meds avatar Jul 20 '22 21:07 j-meds

it's odd it works fine with the string.

Not really. because that is a single item. The other demonstration is a list. Very different when it comes to how dynamo handles it.

If you want this fixed right away, I suggest getting the name yourself with Element.Name and use Clockwork's node called String.ContainsMultiple.

I will try to check it out more in the future, but as of right now, I don't have a lot of time to investigate.

johnpierson avatar Jul 20 '22 21:07 johnpierson

@johnpierson I really appreciate you helping me, It seems that clockwork node doesn't exist anymore and their regex doesn't work with a list that contains multiple list. I went ahead and implemented a python script that merges 2d list as I'm only searching for two keywords. Anyways it would be awesome for multiple strings by using a comma delimited string.

list_1 = IN[0]
list_2 = IN[0]

# Place your code below this line
def Merge2dList(lst1,lst2):
	MergedList=[]
	for index,val in enumerate(lst1):
		print(lst1[index])
		MergedList.append(lst1[index] + lst2[index])
	return MergedList

# Assign your output to the OUT variable.
OUT=Merge2dList(IN[0],IN[1])

j-meds avatar Jul 20 '22 22:07 j-meds