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


#1

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!


#2

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.


#3

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?


#4

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…


(David Cockey) #5

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

#6

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.


#7

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


#8

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="/uploads/default/original/3X/c/5/c53b05c9cca6361abb2bcdedfeac0829a0ef4139.py">TrimCurveInsideClosedCurve.py</a><span class="size">(625 Bytes)</span> 

#9

@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!


#10

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)


#11

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)


Select objects outside a curve? Rhino 5
#12

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

–Mitch

MultiNestedBoundaryTrimCurves.py(4.0 KB)