Grasshopper

algorithmic modeling for Rhino

I'v got a random list of booleans  (e.g. 00000111100001100000111)
I need to count how many true and false values are in this list and produce a new list which is in the same order as original list. (see attached picture for clarification)

Views: 4000

Replies are closed for this discussion.

Replies to This Discussion

Thank you very much for response!
I explained it the wrong way. Sorry, my bad, I'm noob. The main difference is that my list is like in an attached picture

sorry, but doesn't seem to work. Am I missing something?

Ok, now it works! You saved the day!

Solution for noobs:
1) Download and install ghPython http://www.food4rhino.com/project/ghpython?etx

2) Drag python script on canvas
3) Right click, choose "Open editor"
4) Insert this code and click OK

import itertools
a = [len(list(g)) for k, g in itertools.groupby(Boolean)]

5) Right click your inputs and choose list access

It should look something like this:

 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service