Grasshopper

algorithmic modeling for Rhino

Hi guys

I just joined the community and have been working to learn Grasshopper for a month now. I'm trying to create a small algorithm, that will:

1) Take a bunch of lines

2) Figure out their intersections

3) Split the lines at each intersection to create smaller line segments

4a) Identify the line segments that are ending nowhere and delete them - OR:

4b) Identify the line segments that are ending at an intersection point at both ends and keep it - delete all other line segments.

So far I've found the intersections and segmented the lines, but I can't figure the logic to delete the correct lines.

I have attached a screenshot.

What I want is to keep the 3 lines, that create a triangle between them, but delete all the others, which ends nowhere, so I end up with only the 3 line segments that defines the triangle, so it can be joined.

Can you help me?

Views: 4067

Attachments:

Replies to This Discussion

Hi Christian,

This is what I would do:

1. Get the endpoints of your new line segments

2. Test them against the Set of Intersect Points

3. Any where there are 2 matches keep

Components In screen shot: Shatter, Explode(Curve), Create Set, Member Index, Shift Paths, List Length, Larger Than, Cull Pattern

Attachments:

Apologies, 

The Last step (for this case) use Boundary Surface

Hi Danny

Thanks a lot for the quick answer - this solves my current issue completely. Awesome!!

Now I need to work on it, to make it work on a larger scale (with more lines and more internal triangles/squares, etc.) - but this takes me a mile closer to my overall solution.

Thanks again!

Kind regards,

Christian

Better Yet use a cluster and repeat the process

Attachments:

Oh this was a fun one. Almost gave up too.

I used somewhat different logic to shatter all line segments, I couldn't quite work out how your components were supposed to work.

To cull all unwanted line segments, the idea is to:

  • Collect all line segment endpoints in one giant list (G).
  • For both end-points of each line, find the two closest points in G, one of them will be the point itself.
  • If the second closest point is in a different location, then the line segment end is alone in space. If the second closest point is in the same location, at least on other line segment ends there.
  • To test whether the points are in the same place, create a Union Bounding Box. This box will be singular if the points are coincident.
  • String together the boundingboxes for both endpoints and text compare them to see if there's two "singular"s in there.

Writing this now, it would probably have made more sense to measure distances and add them together. If both distances are zero then the sum will be zero. But I went the box->text way instead.

--

David Rutten

david@mcneel.com

Attachments:

Here is my try using ShatterInt and Anemone.

Attachments:

You guys are really awesome!

I was able to finish my algorithm to work with all the lines and curves that I throw into it, and now I'm creating some very interesting designs.

Thanks for your quick help and ideas!

PS. Special thanks to David and Systemig for sharing your ideas, even after Danny already answered. I learned a lot from looking at your 3 different approaches.

Kind regards,

Christian

Hi
Please first thank u David Rutten for your help on this web.
In order to learn more triming lines and curves i need to reuse your posted pic. Here. But i cant read the name of some component. Can u name the component?
Or i will have to look at them by their icons
Which maybe its also a way for learning GH for me.

And can you also tell me how to post a pic. In this comment. Cz i cant find on my mobile screen anything to upload or joint a pic. From my gallery.

Thank a again.

I attached the file, you can just open that instead of deciphering the picture.

I don't think the mobile webpage has options for attaching images/files/links. It's just a plain text field...

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