Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Apply corner radius using setEntirePath()

Community Beginner ,
Aug 03, 2022 Aug 03, 2022

How to apply corner radius to shape using setEntirePath()

TOPICS
Scripting
929
Translate
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
Guide ,
Aug 03, 2022 Aug 03, 2022

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

Translate
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
Community Beginner ,
Aug 03, 2022 Aug 03, 2022

Okay.

Is there any other method to do that in script?

Translate
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
Community Expert ,
Aug 04, 2022 Aug 04, 2022

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

Translate
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
Community Expert ,
Aug 04, 2022 Aug 04, 2022
Translate
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
Community Beginner ,
Aug 04, 2022 Aug 04, 2022

Okay thanks.

But "PointType.SMOOTH" not working for me.

Translate
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
Community Expert ,
Aug 04, 2022 Aug 04, 2022

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.

Translate
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
Community Beginner ,
Aug 04, 2022 Aug 04, 2022

Thank you. But Is it possible to change pointType into

Translate
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
Community Expert ,
Aug 04, 2022 Aug 04, 2022
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. 

Translate
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
Guide ,
Aug 04, 2022 Aug 04, 2022

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];
    }
}

 

Translate
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