# Delete by edge length?

## Recommended Posts

I have a quick question.  Is there a delete by length of edge expression for the delete SOP.    I am animating curves along a "Mountain Grid" that appear by grouping each line of points, and using the add sop to create a line amongst those points.  The only issue I'm having is that the add sop creates a connecting edge between the first and last point of the line.  These edges are by far the longest of any of the lines as you can see in the image, so being able to delete by edge length would be fantastic, or just being able to keep the lines open.  I've also attached the project file.  Thanks for the help!

Mountain_Curves.hip

##### Share on other sites

For your scene just on "add1" SOP set add method to "Group of N points"  and set N as \$F.

For deleting, use Group SOP, on the Edge tab choose Min Edge Length high enough and then append (Edge) Dissolve SOP to that group (instead of Delete SOP).

And for getting that minimal edge length automatically you can convert your polygon (result of Add SOP) to nurbs curve of degree 2 and then use this expression) to get average length of edge. All the long edges are longer then this average, but all other should be shorter.

`if(\$F>1,arclen("../convertToCurve",0,0,1)/npoints("../convertToCurve"),0)`
Edited by pezetko
##### Share on other sites

Thank you so much! Any chance you can explain as to why that works?

##### Share on other sites

First method (\$F in add SOP) works as long as you know the exact number of points in each line (it's same for each line) and points have correct order. You started from grid of known dimensions and orientation, and the growing group has known increment, so from that you can figure out exact point count of each line. It doesn't work on first frame and beyond frame 200. You need to add some condition to check if \$F<2 and \$F>200 to sanitize these limits.

And deleting just works as mentioned, deleting any edges that are longer then average edge length. I added little more explanation directly to my previous post.

##### Share on other sites

Thank you so much, that was great help! Makes complete sense

##### Share on other sites

You can also connect points in the Add sop by a custom attribute. In a point wrangle you could say: f@posz = @P.z;  and then  in the add sop connect points with the posz attribute.

This keeps the last point of the line from wrapping back to connect to the base of the next line.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×