Grasshopper

algorithmic modeling for Rhino

Pickng not consecutive and not null values from a list

Another one. I need to pick a number of values (doesn´t matter which ones), say 5, out of a list that also contain null elements. I don´t want to pick nulls and I don´t want to pick consecutive items... Suggestinos?

THX!!

Views: 876

Attachments:

Replies to This Discussion

Clean tree will remove your null values. If it doesn't matter which ones you choose, only that the indices aren't consecutive, then I'd connect a series starting at some value, step size is 2, number of values is whatever you want, to a list item.

Not elegant in terms of actually testing for the consecutive condition you mention, but it follows the rules.

Brian

Thanks, but that is not exactly what I meant. I know clean removes the nulls from the list but I need them to be there, because I need their index for the selection of every other number. In fact, I´ve inserted the nulls in the list in order to do that. I cannot select just five numbers using series with 2 as an N input because I need to make the selection several times and the numbers selected have to be relatively separated by a certain distance. Basically, I´m selecting domains to make different divisions for a building in plant, for each plant.

Thanks though!!!

I´ve tried rplace nulls by either the next element on the list or the one before, but if there are two consecutive nulls I enter a weird loop...

It could work doing something such as identifying the index of null values without removing them, allowing the code just to pick 5 of the numbers that have every other index than the nulls...

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service