Remove midpoints at specific locations?

How do we find and remove any midpoints as shown here? … these point’s also change in the Z axis.

Straighten line 042503.gh (8.7 KB)

Straighten line 042503_tp.gh (8.7 KB)

basically you will need a some logic, that generates a cull pattern (true/flase yes/no).

as you provide text-input I used a text search with a wildcard (Asterix) * pattern.
you could also query the angle or the z-coordinate or combine multiple conditions.

post some file with internalised geometry to get more help.

hope this helps - kind regards -tom

Hi @Tom_P : Thank you so much for your help. This almost worked … unfortunately it removes ALL of the “z ups” and flattens all the layers of the curve to Z0, it needs it to remove the points only where the the z ups are paired.

One other thing, need to identify or label the lines where the z up pairs used to be, so they can easily be seen in the list.

Straighten line 042503_tp2.gh (14.0 KB)

just sum up the trues of the indices in the list: before, this, next index.
I love expression, but this should also be possible with a few components…

two versions - one using if… one uses casting of boolean to integer

Duplicate thread!

same solution to remove it…


Straighten line 042503.gh (16.7 KB)

@ThomasE, I suppose this is a duplicate … at the time of my post I didn’t realize how similar my questions were … once those segments are straightened I still need to tag those particular lines (circled in blue) with text so the coordinates can easily be identified in the list. Thanks again!

Honestly, I can’t understand what you need, I suggest you manually attach about 20 lines, then manually solve what you expect to happen, how many lines do you plan to get, and what kind of data do you want to get a list of GCode or Point3d.

You talk about lines, points and coordinates, but your input is a gcode text, nobody is going to translate those text to points if you have them and don’t attach the geometry, I also suspect that this could be easily solved in the pre-GCode stage.

Admittedly I have not looked at the others solutions before me & am not intimately familiar with g.code but thinking this could be solved in the geometry stage, pre g.code:

One thought coming to mind is to leverage the “Convex Edges” component and parse the geometry from there.

Here’s a script that returns the midpoints of your red circled portions and your blue circled portions as separate pieces. Is this what you were after or no?

Or if you are trying to delete the red circled areas and keep the blue circled areas my script can do that too. Just remerge the geometry WITHOUT the “Pointed Walls”.

Also a text based response I shared on your other duplicate post:



Straighten line 042503_response_01a.gh (40.3 KB)

@michaelvollrath, Thank you … I get this error when I try to run your file … any suggestions on how to get it to work?

Yes MJD, my apologies, I forgot I was working in Rhino 8 WIP, here is the Rhino 7 version attached.

(Just need to change the Area component to the older version from R7) This should work, let me know if it doesn’t, thank you.

20230428_Straighten line 042503_response_01b.gh (40.8 KB)

@ThomasE my initial post was a poor attempt into breaking the process into components and asking the questions one at a time. Here is the full story of what I’m looking to accomplish. Attached is a g-code generating.gh file with an example of the desired g-code outcome. The points and lines I wished to remove are used to identify breaks or openings in the tool path, I would like to remove those points the tool path to go straight across the opening (represented by the red line) and then be able to add text above and below those coordinates, the test example has been reduced to two layers for easy of editing. Thank you for your assistance and your patience.
g-code generator test.gh (30.8 KB)

@ThomasE my apologies, I’m striking out here on my explanation: where I wrote " delete this line" … I meant I need that line deleted from the code in the script, and where I wrote " remove command/comment from this line" I need the word traverse (or whatever word or command is there) to be removed from that line.

I can’t thank you enough for your help … I’m guessing since your doing this with C# there’s no easy way to do it just in Grasshopper.


You should comment outside… I imagine that
g-code generator test.gh (17.2 KB)

1 Like

@ThomasE I realize that now … this is awesome! Thank you!

@ThomasE After working with this I realized two things:

  1. The breaks in the tool path need to be numbered (N1, N2, N3… etc.)
    and
  2. The Z coordinate, in the string of coordinated sandwiched between the lines of text, needs to be removed. I’d really appreciate it if you could make the adjustments … thank you so much!

what are you planing to print? upload some photos

numbered Insert + Z remove fix
g-code generator test (1).gh (19.4 KB)

@ThomasE …Not printing anything yet, need to get the Slicer dialed in … One more thing, Need semi-colons at the end of each command, but when the Z-is remove in the C# Component so is the semicolon, please adjust.

And, for the numbering of the breaks in the tool path, Would like to be able t change the Starting number. e.g. N2, N3, N4 etc. or N7, N8, N9, etc.

Thanks again

@MJD I updated here!
g-code generator test (1).gh (19.6 KB)

1 Like

@ThomasE the numbers work Great! but the semi-colon doesn’t appear after the coordinates

@ThomasE … what’s the fix? … thanks again, this should be the last tweak.