2

When joining paths in Illustrator, I get a straight line, even if I had vectors at the endpoints. Is there a way to join, preserving these vectors, so I don't have to figure out how to restore them when I actually want them?

i.e., going from this:

broken

to this:

joined

instead of this:

enter image description here

Any help would be appreciated, as this should be so easy.

5

Well you could build a script to do this quite easily. Lets do this:

#target illustrator

var doc = app.activeDocument;
var sel = doc.selection;


if (sel.length == 2){
    pathJoinClosest(sel[0], sel[1]);
}



function pathJoinClosest(path1, path2){
    var pts = path1.pathPoints;
    var pts2 = path2.pathPoints;


    var lastFirst = dd(pts[pts.length -1], pts2[0]);
    var lastLast = dd(pts[pts.length -1], pts2[pts2.length -1]);
    var firstFirst = dd(pts[0], pts2[0]);
    var FirstLast = dd(pts[0], pts2[pts2.length -1]);

    var min = Math.min(lastFirst,lastLast,firstFirst, FirstLast);
    switch(min) {
        case lastFirst:
            break;
        case lastLast:
            pathReverse(path2);
            break;
        case firstFirst:
            pathReverse(path1);
            break;
        case FirstLast:
            pathReverse(path1);
            pathReverse(path2);
    } 
    pathJoin(path1, path2);
}


function pathJoin(path1, path2){
    var pts = path1.pathPoints;
    var pts2 = path2.pathPoints;


    for (var i = 0; i < pts2.length; i++){
        pt = pts.add();

        pt.anchor = pts2[i].anchor;
        pt.leftDirection = pts2[i].leftDirection;
        pt.rightDirection = pts2[i].rightDirection;
        pt.pointType = pts2[i].pointType;
    }
    sel[1].remove();
}


function pathReverse(path){
    var pts = path.pathPoints;
    var len = pts.length; 

    // Swap each pair
    for (var u = 0; u < len/2; u++ ) {
        var l = len - u - 1;

        var anchor = pts[l].anchor;
        var leftDirection = pts[l].leftDirection;
        var rightDirection = pts[l].rightDirection;
        var pointType = pts[l].pointType;

        pts[l].anchor = pts[u].anchor;
        pts[l].leftDirection = pts[u].rightDirection;
        pts[l].pointType = pts[u].pointType;
        pts[l].rightDirection = pts[u].leftDirection;

        pts[u].anchor = anchor;
        pts[u].leftDirection = rightDirection;
        pts[u].rightDirection = leftDirection;
        pts[u].pointType = pointType;
    }    

}

function dd(pt1, pt2){
    return Math.pow(pt1.anchor[0]-pt2.anchor[0], 2)+
           Math.pow(pt1.anchor[1]-pt2.anchor[1], 2);  
}

Well joining was easy, implementing closest point was not so succit. Implementing more than 2 paths and implementing selected control points and closed paths is just raw work so i stopped at join closest points of 2 paths.

Now if one could only make adobe treat scripting sanely so that one could bind that to a shortcut.

|improve this answer|||||
4

Probably not the answer you're looking for....

There's no automated way to join paths and continue bezier curves.

I handle situations like this by drawing a section to be joined. Then select the connection anchors on each path and use Object > Path > Average and Object > Path > Join at the same time via a little known or hidden shortcut.

Hidden shortcut to average AND join anchors in one step.

Holding Command/Ctrl+Option/Alt+Shift and tapping J will average (both vert and horiz) and join two anchors in one step.


So guestimate the connection path... average+join the end anchors and refine if necessary.

enter image description here

This still relies on you eyeballing things a bit, but it's often better than dealing with curves being entirely reset.

|improve this answer|||||
0

Only manually, you would have to click one of the end points then click the other one and drag without releasing the mouse button until it looks about right. Then use the A tool to further adjust the resulting curve.

The built-in 'Join' command only connects via a straight line.

|improve this answer|||||
  • I know it connects only with a straight line, and I typically do adjust it after, but it's not always exact, which is sometimes unacceptable in cases when you have two paths ontop of each other where they must align exactly. – Codesmith Jul 6 '17 at 21:41
0

I'm guessing you're using the pen tool, clicking one endpoint and then clicking the other.

Try clicking one endpoint, click and hold/drag the second endpoint.

Make the curve you want, then restore the corner join to rounded with this:

enter image description here

|improve this answer|||||
  • But that would move the original handles and alter the existing curves... – Luciano Jul 7 '17 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.