Grasshopper

algorithmic modeling for Rhino

Hi All,

Big fan of grasshopper and these forums and I've always come here for help, this just happens to be the first time I couldn't find the answer to my question in a previous post.

I have a single discontinuous list of index numbers and I'd like to be able to generate a set of domains where each span of numbers would have its own domain.  For example:

This list: 5,6,7,8,9,22,23,24,25,26,77,78,79,80,81...

Would give these domains: 5 to 9, 22 to 26, 77 to 81...

I'm at a loss as to how I can achieve this though.  I know I can use the bounds function on the list but that would give a single domain, not several.  In case it helps the list in question was generated by a true/false cull pattern from the complete list of indices so simply determining the indices of the beginning and end of each chunk of 'trues' in the cull pattern would work as well as it would give the same domains. I can post an example file if anyone would like but I figure this is a pretty general issue.

So anybody have any ideas on how to solve this multiple domains from a single list problem?  Thanks in advance for any help at all, I'd really appreciate it!

James

Views: 6768

Replies to This Discussion

It's a bit of a long hike, but this is a solution:

The idea is:

  • Create all domains between all successive numbers.
  • Remove all domains that do not have a length of 1.
  • Create line segments based on the remaining domains.
  • Join the line segment into polylines, this will merge consecutive lines/domains.
  • Extract the end-points and sort the X-values (joining will destroy curve order).
  • Recreate domains from the end-points.

This will delete any lone values, is that what you want?

--

David Rutten

david@mcneel.com

Attachments:

Wow, this is great.  I can honestly say I never would have thought of using lines here.  It's exactly what I needed, thank you.  It does miss out on any single number domains (if that even counts as a domain) in the initial list but that's not an issue at all for what I need this for.  

Once again, thanks!

The ancient Greeks treated all numbers as sticks with varying lengths. To them, all of algebra was geometry.

--

David Rutten

david@mcneel.com

Hi James, David,

maybe I'm missing something, but I was thinking of using the Partition List:

That what I tried first too, but that solution only works if you know the lengths of each subdomain to feed into the S variable.  Since that's not the case here Partition list doesn't seem to be the solution.

Ah! Now I see what info I missed and why my reply isn't contributing~ sorry about that.

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