Grasshopper

algorithmic modeling for Rhino

Replace values in a list due to greater than component

I'm trying to replace a list of values if they are smaller than a certain number. I understand you dispatch the list due to a pattern using the less than component. Once I have those values I'm not sure what to do to replace them with a number. I'm assuming once I'm able to replace them I merge that list back in with the list that was dipatched so that their in the original order or position within the branch. I'm also not sure how that would work. Any help would greatly be appreciated.

Views: 9709

Replies to This Discussion

Have a look at this.
Attachments:
Thanks for the help. That's how I approached it but the end result I was going for, using your example of a random list, was to maintain the original amount of branches (10) i.e. containing the numbers 8, 4, 2, 10, 1, 3, 8, 4, 2, 0. But then for the end result to maintain all numbers above 5 but replace all numbers below with a defined number..Let's say zero. So then the list would read...8, 0, 0, 10, 0, 0, 8, 0, 0.
I'm in the same position but this example didnt seem to work. I have a list of extrusion heights and any height under .9 needs to be converted to .1 but this only adds a certain amount and doesn't replace them, and I need all the values to maintain the same order in the list. Anyone else?
You could use the weave component to compile the list at the end with a bunch of zeros (see first image), but I think a much simpler method is to use GH's Min component that will select the the smaller of two numbers from two lists. By using the boolean pattern to create an arbitrarily large number when a number is to be kept you can have the zeros selected for everything else. (see Second Image)


Hey Danny,
I ended up just doing as you suggested a while back, using a min. number, but it still doesn't give the results I was looking for. It only gave the min number set, as I'm sure you know. When a list of values are not below that number but close is problem that I was facing. In the example posted the panels open and close based on the distance of the center point of that panel to a attractor. The area within the red are supposed to have a value of 0. This would make the panels be completely closed. Since the panels centerpoint can never have a value of zero because the centerpoint and the attractor would have to have the same location I'm trying to take values below a certain value and replace them with zero. I resolved to just go in and replace the panels that I wanted with a zero value with the appropriate panel which didn't take that long but in experimenting I was just trying to optimize the definition.
Attachments:
Hi Matthew,

I don't understand the bit about "When a list of values are not below that number but close is problem that I was facing" It should either meet your criteria or not there shouldn't be a grey area.

Have a look at this example to see if it helps with your own. The GHX file is in v0.7xxx

If you have a problem reading the image right click and open in new tab.
Attachments:
Thanks Danny, that was what I was trying to achieve.

Is it posible to replace more than 1 value at the same time??

lets say I have a list of numbers

0,12

0,13

0,17

0,56

0,58

0,59

0,83

0,86

0,89

and I wanna replace everything for 0,15_ 0,55_0,85 so I would end up with

0,15

0,15

0,15

0,55

0,55

0,55

0,85

0,85

0,85

is this possible?

 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service