In Grasshopper, you can extract list items by their name. Match Text looks for strings resulting in a True/False pattern.
New to Grasshopper? I suggest you read this article in the first place.
Need more learning resources? Check this out.
Disclaimer
As you will see in my screenshots most components carry a title above them displaying their name. This is because I use a plugin called Bifocals.
Also you’ll see my Grasshopper tab titles abbreviated because there’s not enough horizontal space. I will mention the titles in full in my script though.
As with everything Grasshopper, the technique I show you is no way my own discovery. This time, I got the idea from the McNeel forum.
Match Text: Why?
The other day I did some Surface Morphing taking 2 sorts of elements – Breps and Surfaces. As it goes, some flattening before Morphing led to a 1-Path-List of items containing both of these elements:
My plan was to deal with the 2 types of elements separately furtheron. (In this case, utilizing them in ARCHICAD.)
I couldn’t figure out how to extract Breps and Surfarces separately in the first place.
I tried to tweak my flattening before Surface Morphing to recreate a suitable tree structure as a result – which would have allowed me to take things apart as described here.
This didn’t work for me – whenever I changed things my morphing went sideways.
Anyway I was curious how to get a list separated by the names of its items. The usual List and Cull components seem to be completely index-fixated. (I am glad to be told otherwise.)
On Discourse.McNeel I found the solution with Match Text (Set – Text):
When you connect it to your list output …
… and feed it with a Text Panel containing the text *Brep:
… then you’ll see that Match Text produces a True/False pattern. This True/False pattern matches the occurrence of list items containing the string Brep at the end.
* is considered a wildcard that allows for any value. Place it before, after or on both sides of the string you enter, depending on the position your string has in each list item. I could as well have written:
- *Bre*
- Closed*
You get the idea.
Now the sorting issue – by list item names – is done. We can proceed by utilizing Match Text’s True/False output in a suitable list wrangler. Dispatch comes to mind:
We have to connect it this way:
Done.
For a good introduction on Grasshopper’s Data Trees read this page from TU Delft.
New to Grasshopper? I suggest you read this article in the first place.
Need more learning resources? Check this out.
© Horst Sondermann 2019 // All Rights reserved
Leave a Reply
You must be logged in to post a comment.