Mobile app version of vmapp.org
Login or Join
Ravi4787994

: Illustrator: how to join paths while preserving vectors 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

@Ravi4787994

Posted in: #AdobeIllustrator #HowTo #Path

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:



to this:



instead of this:



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

10.04% popularity Vote Up Vote Down


Login to follow query

More posts by @Ravi4787994

4 Comments

Sorted by latest first Latest Oldest Best

 

@Gail6891361

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.

10% popularity Vote Up Vote Down


 

@Turnbaugh909

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.



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

10% popularity Vote Up Vote Down


 

@Annie732

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:

10% popularity Vote Up Vote Down


 

@Ravi4787994

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme