johnpierson / RhythmForDynamo

A collection of nodes for use in Dynamo with Revit.
BSD 3-Clause "New" or "Revised" License
110 stars 25 forks source link

Add support for multiple strings in "elementFilter" #49

Open j-meds opened 2 years ago

j-meds commented 2 years ago

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>
johnpierson commented 2 years ago

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

j-meds commented 2 years ago

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

johnpierson commented 2 years ago

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

j-meds commented 2 years ago

@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

johnpierson commented 2 years ago

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

j-meds commented 2 years ago

@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 commented 2 years ago

updated images

johnpierson commented 2 years ago

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

j-meds commented 2 years ago

@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.

johnpierson commented 2 years ago

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.

j-meds commented 2 years ago

@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])