Apply corner radius using setEntirePath()

New Here ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

How to apply corner radius to shape using setEntirePath()

TOPICS
Scripting

Views

119

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

Not possible.  You can't make smooth points with setEntirePath().

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 03, 2022 Aug 03, 2022

Copy link to clipboard

Copied

Okay.

Is there any other method to do that in script?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

setEntirePath() takes care of the Anchor points, after that you'll have to set the Handles of each Anchor. It's quite a bit of Math, but it can technically be done

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Okay thanks.

But "PointType.SMOOTH" not working for me.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

PointType is ReadOnly, it's used to find out what kind of point we're dealing with, not to change from corner to smooth or viceversa.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Thank you. But Is it possible to change pointType into

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

LATEST
quote

Thank you. But Is it possible to change pointType into


By @Ashu24845488rcnx

 

I'm not sure what you're asking. Can you elaborate?

 

If you mean if it's possible to change a corner point to a smooth point by using the PointType property, no, it's not possible. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Aug 04, 2022 Aug 04, 2022

Copy link to clipboard

Copied

Here's a roundedRectangle() function with the same syntax as rectangle(), but with an added corner radius argument.

 

// e.g. of function call
roundedRectangle(
    -25 /*top*/, 25 /*left*/, 50 /*w*/, 50 /*h*/, 10 /*cornerRadius*/);

/*
 * roundedRectangle by Femke Blanco
 * Beta 04/08/2022
 */
function roundedRectangle(top, left, w, h, r) {
    var paths = app.activeDocument.pathItems;
    var path1 = paths.add();
    var p;
    var c = r * ((4 / 3) * Math.tan(Math.PI / 8));  // handle length
    // p2
    point(left + r, top, left + r, top, left + r - c, top);
    // p3
    point(left + w - r, top, left + w - r + c, top, left + w - r, top);
    // p4
    point(left + w , top - r, left + w , top - r, left + w , top - r + c);
    // p5
    point(left + w, top - h + r, left + w, top - h + r - c, 
        left + w, top - h + r);
    // p6
    point(left + w - r, top - h, left + w - r, top - h, 
        left + w - r + c, top - h);
    // p7
    point(left + r, top - h, left + r - c, top - h, left + r, top - h);
    // p8
    point(left, top - h + r, left, top - h + r, left, top - h + r - c);
    // p1
    point(left, top - r, left, top - r + c, left, top - r);
    path1.closed = true;
    function point(x, y, Rx, Ry, Lx, Ly) {
        p = path1.pathPoints.add();
        p.anchor = [x, y];
        p.rightDirection = [Rx, Ry];
        p.leftDirection = [Lx, Ly];
    }
}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines