Grasshopper

algorithmic modeling for Rhino

I have 10 branches in a tree. In each branch I have a collection of points.

What I want to find out is how many points there are in each branch.

I can get the amount of total points in the whole tree by flattening it and doing list length. But is it possible to flatten only the branches and then do a list length that will give me the number of points in each branch?

Views: 6123

Replies to This Discussion

You don't need flatten at all. Just use List Length on the entire tree and you'll get lengths for each branch in the tree.

--

David Rutten

david@mcneel.com

Poprad, Slovakia

Sorry, I forgot to mention that in each of the 10 brances, area sub-branches as the data is originally collected from polylines, so a sub-branch for each polyline. I'm using "Control Points" to collect the points from the polylines.

This is my resault from using list length on entire tree.

Branch 0

Polyline 1 {0;1}  ->  Point count

Polyline 2 {0;2}  -> Point count

...

Branch 1

Polyline 1 {1;1}  ->  Point count

Polyline 2 {1;2}  -> Point count

...

This is the resault I want

Branch 0

{0}  ->  Total Point count of all branches in {0}

Branch 1

{1}  ->  Total Point count of all branches in {1}

So in theory what I want to do is "Flatten Tree" but on each of the initial 10 branches. Or retrieve the sum of all items in each branch to say it differently.

You'll have to use the [Path Mapper] component. 

{A;B;C}           ->          {B}

should do the trick. 

Ahh, thank you. My tree was only at a second level of branching {A;B} so this did the trick.

{A;B}     ->     {A}

As I understand it correctly, it takes all the B branches in each list and flattens them onto a single branch at level A.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service