algorithmic modeling for Rhino
Hi, the image represents areas of a number of split surfaces. How can I select the larger of each set for deleting? I'm confused about whether I use the List components or Tree components to access the data.
It seems like I should be able to input the list to the Larger Than component, with one input shifted but that is not doing the trick.
Eric
Tags:
GH and coding sometimes makes you think in different terms and stategies. Building a definition is like chess: you have to think ahead a few moves. What sounds reasonable in the first move may lead nowhere further on...
Larger or smaller than needs to compare two values and get one result. To find the largest, you would need to compare each item with all the others, then combine those results... pretty complex once you have more than two values.
There are pretty effective solutions to sort a list. This will always give you the largest item last (or first). You can easily delete that item with ShiftList, Delete or Cull. If you don't want to change the order of your list but cull the largest, you can parallel-sort a series representing the original indices. The last(/first) index after sorting will indicate the index to the largest item in the original list. Use that index to delete the largest item.
Oops, replied to myself. See above.
Eric
Hi Hannes,
I only need to compare each pair of surfaces (0 and 1 indices) not the entire list to itself. Then delete the larger of each pair.
Eric
Same logic applies to a list even with only two items:
You'd need to compare A to B. That means extract the first item and the second (ListItem). If A is smaller than B, delete B, otherwise delete A. (here's a trick with booleans: true computes to 1, false to 0. So you just need put the result of the comparison as index into DeleteItem).
On the other hand: SortList will compare and switch both items, when necessary. Now you can always delete the last item.
Keep in mind: the opertions will be calculated for each list seperately. You have several lists of two items each (light yellow lines separated by greyish yellow)
ListItem was the hint I needed.
I can't find a DeletItem component. This is the biggest difficulty I find using GH. If I know a component exists but don't know exactly what it is called or where to find it in the palettes, it's just endless searching of palette after palette.
Eric
btw: You can doubleclick on the canvas and just type to find a component by name. This won't work for if the component isn't called as you'd expect of course ;)
Wow! I had no idea...
Sorry for confusing you. The component I was referring to is CullIndex.
The result of the comparison is just a boolean value that says "true" if A is larger than B and "false" otherwise. Those values convert to 1 and 0 as mentioned above. You would want to delete(cull) the item from the list of split surfaces, obviously.
Top part works for cases with only two subsurfaces after the split.
If you want to make sure everything works even when there are three or more parts after the split, use the bottom version.
Hannes,
That works beautifully. Thanks for taking the time with a newbie.
Eric
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by