I know this has come up before however haven’t been able to achieve what I’ve seen in other support articles. In the image below its grabbing the 1 from search for and adding linking that with 0051.
As a side note, i am also having issues pasting in the python shown below (which seems to solve my issue). In short i have added code via the parent / child method shown in the primer but python appears to be a different workflow. Help a noob?!
For the python script, create a Python Script node, double click the node until the Python Script window pops up. Delete everything in it, then paste the code from the link. It looks like it uses two inputs so click the + button. IN[0] is the main list and IN[1] is the item to check matches against. As to why it might not work, I am having a hard time understanding what you want. Can you explain what it is you actually want to happen?
The python script you are referencing only allows for a single item to check exact for the entire list. You have a list of items to cross-lace with, which will not work with that script.
ok, i got that far with the python node but it still produced an error which i figured was because in[1] was expecting a single string and i was giving it an array (so a single string at in[1] works). I thought maybe there was some package i had to download from python to get it to work. regarding the following script - how do you take in[1] and make it accept an array? Sorry for the noob question, plan to learn python soon!
import re
output=[]
for i in IN[0]:
if re.match(IN[1],i):
output.append(True)
else:
output.append(False)
OUT = output
Maybe the python route is not the way to go. From the image in my first post - i’m using string.contains to match up the room numbers from the arch model to the space “room number” in a mechanical model to add parameters from arch rooms to mech spaces. My solution of padding seems to work but the problem in my first image (in the case of 51 at [1]) is that when i try to cross it with the list of rooms (or spaces) from the other model its taking “1” (at [75] and saying that its in 0051 which is true, but i would like it only say true if its an exact match. Like I said if its padded 0001 it seems to give me what i want. Just curious if there is another way?
I’m not 100% sure what you’re trying to accomplish… You’re searching for only the “1”, correct? So why are you feeding the 1034 item list into String.Contains? With cross lacing, no less, which is why that list is 1.2 million items…
The reason you get so many true's from List.ContainsItem is because it looks likely that every sublist from the node before it contains at least one true because of the cross lacing. Every single combination is being matched- you might not even be looking at the item you’re looking for, just one that happens to line up with that index in a sublist.
If you want an exact match for “1” as a string, you should never end up with “0051”, so an ‘exact match’ is maybe not what you’re looking for to begin with…? Why aren’t you simply searching for “0051”?
You could try finding all items containing “1”, perhaps as the last character (String.EndsWith node) and then filter that list for other requirements.
If it’s the smallest number you could even just sort and take the first item:
Are you looking for any number with a 1 or an exact match? You’re currently searching for all 1034 values and returning any list that contains any one of those values.
1 and 51 are just on example, i need to cross all of them.
what i am trying to do is get two matching lists - one that contains all arch room numbers from a link and all spaces and the room number from the space that have been pushed from the arch model using the analysis tab. because not all of the spaces are in the arch model i need to filter the list so that i get a 1 to 1 relationship (matching list length) between the lists. Once i get that relationship i can then push a shared parameter to the spaces. Example - so one room number may be 51 one space number may be 1 - they are not equal, i should not get true but because 1 is in the number 51 i am getting true which i understand because 51 contains a 1… I was hoping that because 1 and 51 are not exact that it would list a false. If i pad the 1 to list it as 0001, 0001 is not in 51 so i get the result I want. Was just curious if there was a node that would eliminate the need for padding.
No idea why padding seems to help but I think the issue is your list structure.
Just so I’m clear, you have a list of linked room numbers and a list of space room numbers. The lists are not equal length and not in order, but you want to match them up 1 to 1.
Thanks Nick, i retried the method you had with “==” and it works. Must have been a list structure / levels issue. Either way works with both padding and “==”. Thanks again!