Grasshopper

algorithmic modeling for Rhino

I'm trying to remove short segments of polyline cells in a voronoi. I want to replace the vertices of short line segments with an average of the points and to end up with points that I can recreate new polylines from.

I got close to this with GH components but could not replace the points in all cells with the new averaged points - only the points in the cells that contained the short line segments, not the points in the cells that shared the points but not the lines.

So I'm trying to do this with VBScript (although willing to look at any language)

I have...

 - a list of all the vertices for each cell,

 - a list of points that need to be replaced by an average

My method was going to be...

For each branch of PointsToAvg, calculate the average point.

For each point in current PointsToAvg branch, search it in PointsToModify and replace with Average Point

    For each Branch of PointsToModify

        For each Item in Branch
        If matched with any of the averaged points, replace point with average point.

Can anyone help me out with this please? I've tried looking for similar code to butcher but had no luck!

Views: 1478

Attachments:

Replies to This Discussion

Actually, that PointsToAvg Input is not right... back to drawing board :(

Only just seen your reply, but this will work for most of the central ones if averaging is OK. It uses cull points with an average, culling lines by length and closest points.

However, you might want to extract the edge curves before running through this logic as at present, if a short segment occurs next to the border it will a shift these too:

Attachments:

Thanks for the reply Joe! That's a smart solution.

I had forgotten about the short lines next to the border and I need to preserve the voronoi cells in the output too so I need to keep searching for a way to do this and my original method won't work with averages!

This is driving me nuts!

Today's award for achieving what I've been trying to do for 2 days with only 4 components goes to...

Nice one! Thank you!

Haha. Hesitant to post this now I've seen how much I overcomplicated the last one...!! But this will preserve your points if they are on the rectangular border - I've no doubt it could be reduced down heavily by someone with a sharper mind than mine (Mondays eh?).

Attachments:

Nice! Thanks again!

Compared to what I'd been doing, you hadn't over-complicated much!

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