Grasshopper

algorithmic modeling for Rhino

Retrieve Branch Path according to Number of contained Items

Hi everybody,

I wish to extract branch paths depending on how many items AND depending on the value of the item(s) they contain.

I've got a data tree with each branch representing a single line and containing the parameter t of line intersections. The number of items/entries range from Null to Two. The value of items could be 0.0, 1.0 or a floating point within the range of 0.0 and 1.0

What I need is a list of all (original) branch paths, that contain

(A) two items

(B) items inequal to 0 and 1

_______________________________________

Basically, my actual problem ends here, but with respect to this problem, I started to wonder, if the number of items, a branch contains, is a parameter, that could be extracted and processed in further operations. Can you tell me something about that?

Finally, I need to mention that I am a beginner with GH, which is why I hope, there could be a solution build with GH components only.

Anyways, thanks a very lot,

Christian

Views: 3336

Attachments:

Replies to This Discussion

Try This.. 

Its as simple as I can think to do it. It make possible to do it with less components but may not be so readable.

Attachments:

Thanks a lot for your simple but easily comprehensible solution, Matt.

Your approach solves my problem (A) since it is about the amount of items cotained in a specific branch.

Regarding problem (B) I am looking for a method to evaluate the items as the determining constraint on the basis of which I then want to retrieve a specific branch.

In other words:

I want to check if the value of an item inequals 0.0 or 1.0 and if this condition is satisfied (e.g. the value could be 0.54998), I then want to retrieve the respective branch (path).

Any ideas on that?

And I'd like to add one more request to that topic:

now that I have a data tree containing all desired branches, where each branch represents a line I later on want to further work with, how can I convert the branch paths into a list where each entry equals the original branch number/ "ID"?

Does this Work?

As for you new question I can't updated the attached code with the Ids in this reply but use a Deconstuct Path Component as below in the screen capture

Attachments:

I am still not done with Problem (B), which is probably on my behalf:

The way you dealt with my question was to design a data tree, in which branches with only one item are the only ones to contain the floating point items (i.e items with value of e.g. 0.54998). By this, you only need to cull all branches with the length of N=1, as you did it, and you would have all branches with floating points.

In fact, my data tree also comprises branches with only one item, which could be of the value 0.0 or 1.0 too.

As I stated in my initial post (and I admit, I actually didn't do that precisely), my culling criteria are

(A) branches with TWO items, no matter if the values are

0| 0.0

1| 0.4235

or

0| 1.0

1| 0.0

or

...

(B) branches with ONE item (since the two-item-branches are already culled with criterion (A)) of the value inequal to 0.0 and 1.0 

It is therefore crucial to pick all the (remaining) branches (with one item) and check the contained item for inequality against 0.0 and 1.0 and not to check for the length of branches only.

Anyways, I appreciate all your efforts, you invested so far. Thank you Matt!

Ok, I had made a list of number with 0,1  as sets of 2 per tree and floating points as singles so was not getting the 'error'/ answer you required.

This update should work how you want it to now, just added the extra condition.

Attachments:

And here we are, thats what I was looking for.

Many thanks to you, Matt.

If you can post up the portion of your code with the data internalised for the question, it should help speed up the answers another time. ;)

As may miss something like {0.0, 0.055 } when making the demo based on your screen capture only. 

P.s Glad it finally works as expected.

Good advice! I will store it directly behind my forehead ;)

Once again, thanks a lot.

As I understand it, you want only branches that contain a single item, that is not 0 or 1, right?

Attachments:

Thank you, too, Pieter. I applied your approach to my problem and kept it as an alternative method. Getting to know new components (Prune Tree, Mass Addition) and how they could be applied is benefit enough.

On this occasion, may you tell me what the logic of the Mass Addition component is in detail? Your example shows, that true/false entries are added up in a way that

False+False = 0

True + False = True + True = 1

but, to be honest and by this probably compromising myself, I do not recognize the superior mathematical logic behind it. In other words, is there a specific term for this kind of boolean operation?

I'd appreciate a short explanation.

Thanks in advance!

Hi Christian,
I never claimed I was using any superior logic there...;) but anyway,  
the PruneTree culls all branches that contain more (or less) than one value (I figured that was a quick partial solution).
Then I tested whether the value is 0 or 1, then I used MassAddition to end up with a single result. I have this tendency to use MassAddition in conbination with the boolean value property that anything but 0 results in a True value (auto conversion I guess). Hope that makes sense to you and explains what I did there... ~

(Just curious: wieso schreibst du Constance statt Konstanz? )

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