Delete and trim all curves that lie within a closed curve?

Is there any tool that will quickly delete all curves within a closed curve which may or may not intersect the closed bounding curve? This tool would be highly beneficial. My “Trim” and “Delete” process just seems way to slow.
Thanks!

1 Like

If a planar result is okay, CurveBoolean with the command line option DeleteInput=All could work for you. Select all curves, run command, then click outside your closed curve.

If you want to keep the intersecting curves outside your closed curve and all are coplanar, don’t select those intersectors with the curve boolean. Select them all at once, run split and choose the closed curve. Deselect the curve parts you want to keep, and delete the rest.

Thanks Greg, the second method you mentioned is essentially what I am doing and can be very slow to select/deselect the curves you would like to keep/delete. Especially when the closed bounding curve is curving and your are working with many small lines.

I feel as though there should be a tool that allows you to delete/trim all the curves inside/outside a closed planar curve.
Hmm, perhaps this doesn’t exist and should be added to the wish list?

Sorry, maybe somebody has a script worked up already to help. Or possibly lasso selecting might be helpful?

Meanwhile, if you’re comfortable with Grasshopper, the Containment component could be helpful for testing whether the split curve endpoints are inside the closed curve…

Does this work for you?

  1. Split command
  2. Objects to split - select all curves which may cross the bounding curve
  3. Cutting tool - select boundary curve
  4. Enter to split the curves
  5. SelBoundary command
  6. Select boundary curve. Curves inside the boundary are selected
  7. Delete command
1 Like

There are a few selection options that might help.

  1. the paint brush is great for irregular selections.
  2. select all curves might help. The deselecting the few as opposed to selecting the many.
  3. I believe there is also a select curves by length. i.e shorter than. that might do it.

Explore the selections tab and options. certainly something there will help you.

Attached is a script that does what you want… @pascal I have requested this as a V6 integrated feature, hope it’s on the list…

BoundaryTrimCurves.rvb(3.7 KB)

This one can take multiple boundary curves:

MultiBoundaryTrimCurves.rvb(4.6 KB)

–Mitch

Hi Pablo
Try this attached Python script

import rhinoscriptsyntax as rs
def trim_internal():
    while True:
        cut_curve=rs.GetObject("select cut closed curve <Enter to exit>",4)
        if cut_curve==None or cut_curve=="":break
        curves=rs.ObjectsByType(4)
        i= curves.index(cut_curve)
        del curves[i]  
        rs.EnableRedraw(False)
        rs.SelectObjects(curves)
        rs.Command("_Split selid "+str(cut_curve)+" _enter",False)
        rs.UnselectAllObjects()
        rs.Command("_selBoundary selid "+str(cut_curve)+" _enter",False)
        rs.Command("delete",False)
        rs.EnableRedraw(True)
    
trim_internal()```


You must select only closed curve

Ciao Vittorio
<a class="attachment" href="https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/c/5/c53b05c9cca6361abb2bcdedfeac0829a0ef4139.py">TrimCurveInsideClosedCurve.py</a><span class="size">(625 Bytes)</span> 

@vittorio

Thank you for your python script! I was wondering if you could make a version that can select multiple closed curves at a time to trim their respective interior regions? I know calling rhinoscript you can “GetObjects” but I am not sure how to remanage the other commands to take on multiple variables at once. Thanks!

Hi Heisenberg

below the script modified like you want. Let me know if it is OK:

    import rhinoscriptsyntax as rs
    def trim_internals():

    while True:
        cut_curves=rs.GetObjects("select cut closed curves <Enter to exit>",4)
        rs.EnableRedraw(False)
        curves=rs.ObjectsByType(4)
        if cut_curves==None or cut_curves=="":break
        for cut_curva in cut_curves:
            curves=rs.ObjectsByType(4)
            i= curves.index(cut_curva)
            del curves[i]             
            rs.SelectObjects(curves)
            rs.Command("_Split selid "+str(cut_curva)+" _enter",False)
            rs.UnselectAllObjects()
            rs.Command("_selBoundary selid "+str(cut_curva)+" _enter",False)
            rs.Command("delete",False)
        rs.EnableRedraw(True)

trim_internals()

Ciao Vittorio

TrimCurveInsideClosedCurves.py(745 Bytes)

the new version is best:

import rhinoscriptsyntax as rs
def trim_internals():
    while True:
        cut_curves=rs.GetObjects("select cut closed curves <Enter to exit>",4)
        if cut_curves==None or cut_curves=="":break 
        bb=[]
        for c in cut_curves:
            if rs.IsCurveClosed(c):
                bb.append(c)
        cut_curves=bb
        rs.EnableRedraw(False)
                     
        curves=rs.ObjectsByType(4)  
        rs.UnselectAllObjects()
        stcut="" # stringa vuota per selezionare curve di taglio in Command        for cc in cut_curves:
            stcut+=" selid "+str(cc)
            i=curves.index(cc)
            del curves[i]
        rs.SelectObjects(curves)        
        rs.Command("_Split  "+stcut+" _enter",False)
        rs.UnselectAllObjects()
        for cut_curva in cut_curves:
            rs.Command("_selBoundary selid "+str(cut_curva)+" _enter",False)
            rs.Command("delete",False)
        rs.EnableRedraw(True)

trim_internals()

Ciao VittorioTrimCurveInsideClosedCurves.py(832 Bytes)

Here is my (late) entry into the field… Works with nested curves as well !

–Mitch

MultiNestedBoundaryTrimCurves.py(4.0 KB)

1 Like

Has this ever been added into the product as a command in Rhino V7?

If you look on the right side, what I’m hoping for is a single command which automates the process of:

  1. Splitting all of the blue lines with the red spheres…
  2. Removing the red spheres…
  3. Removing the split lines within the red spheres.

In other words, a BooleanDifference on a set of curves, using a set of surfaces.

Is this possible within a single command? The manual steps above is super time consuming for the sheer # of times I’m doing this for different poses.

Hello - no, this does not exist in Rhino.

-Pascal

Darn! Seems like boolean operations on curves would fit right in with the vast amount of other handy commands Rhino has :wink:

Here’s a follow up then…

Let’s say I split my blue lines with the red spheres. I then select only my red spheres. Is it possible, even through scripting, to then select all curves found within the volume of my selection? In other words, it would select all the split curves inside of those spheres. Then I could simply hit delete :slight_smile:

In psuedo-code terms:

  • If a valid set of closed surfaces/polysurfaces are selected…
  • Iterate through each object…
  • Within each object’s volume, select any curves.

Hello - SelVolumeObject may help.

-Pascal

could you modify the program so the closed curve and the lines inside are a group?