Continuously connect into chain

I’m trying to figure out if there is a way to continuously trim curves into a chain. Right now, if I do “Connect repeat” and set Join=Yes then I select my first segment, then the second segment, it joins them, but now I must re-select the combined curve before selecting the third. I’m trying to avoid this unnecessary re-selection of the previously combined segments.

So, I would just start the command, select segment 1, then 2 those would be joined and the result would automatically be selected as the first curve for the next connect, then just select 3, and continue. So, I would just need to select each segment exactly once instead of twice. It would avoid a lot of re-selecting. In my opinion this is the way Connect Repeat should always work, or at least there should be an option for it to be a continuous selection.

Is there a way to do this and I just don’t know what it’s called? It seems like an obvious way to trim multiple curves into a continuous chain.

Hi James - there is currently no such tool (unless the curves form a closed 2d loop, in which cse CurveBoolean can help) but it seems possible to make something that does that. It’s somewhat of a book keeping headache but it should be possible to make this work at least with ‘properly’ intersectiing curves, maybe quite a bit harder if the curves overlap. @James_Richters can you post one or two sets of curves that you’d like this to trim and join?

-Pascal

Hi,
I had some free time so I made you a quick script to do this :slight_smile:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def join_curves_continuously():
    curves = []
    while True:
        curve_id = rs.GetObject("Select a curve", 4)
        if curve_id is None:
            break
        curves.append(curve_id)
        if len(curves) > 1:
            joined_curves = rs.JoinCurves(curves, delete_input=True)
            if joined_curves:
                curves = joined_curves
    if curves:
        rs.SelectObject(curves[0])

join_curves_continuously()
1 Like

@Pascal Here is an example… I want to connect the curves on the left to be the closed curve on the right:

sample continuous trim.3dm (36.6 KB)

@farouk.serragedine Thank you for writing a script. It does join things continuously, but I also want to trim/extend them… the same as using _*Connect with Join=Yes

Ah, so they do not already intersect… that is iffier…

-Pascal

Sometimes they already intersect, most of the time they do not. I would select the curves at the correct points so _*Connect would work on both ends.

Hi James - probably hard to do this relialbly all in one go but it may be poissible to make it work if you click on each curve in the bit that you want to keep.

-Pascal

@pascal I would click as illustrated below:

Hi,
Sorry for my late reply
This should do exactly what you wanted :blush:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

def join_curves_continuously():
    curves = []
    while True:
        result = rs.Command("_Connect Join=Yes", False)
        if not result: 
            break
        joined_curves = rs.LastCreatedObjects(select=True)
        if joined_curves:
            curves = joined_curves
    if curves:
        rs.SelectObject(curves[0])

join_curves_continuously()

@James_Richters

@farouk.serragedine Thank you for the script, but it still has the same issue, I have to re-click on the previous selection… For my example I want to only make 5 selections, like this:

I’m trying to figure out how to automatically use the point selected for ‘Select second curve to connect’ as the first point for the next segment, so I don’t have to re-select what I already selected.

The way it is now, I would have to make 8 selections. This is just an example but when you have a lot of it to do and each selection requires zooming in and out to be accurate enough, it’s a slow down to bother re-selecting what was already selected.

If I had 60 segments to trim I should be able to do it with 61 selections to make a closed curve, but when I need to re-select what was already selected, I would need to make 120 selections, and it’s tedious, because you can’t double click the section, you need to pause for long enough, so it’s not considered a double click, otherwise it won’t re-select the curve. It would be so much faster to just click each segment once.

The problem I have trying to make this work is that _Connect automatically does ‘deselect all’ so I can’t give it the previous selection as the start to the next one. I know why it does this, it’s because it needs to know precisely where the selection was made so it knows what side to trim on.

James