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

-- Javascript/illustrator [change rounded rectangle corner radius]

New Here ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Can someone help me to change the radius of a pageItem with Javascript. I can change the width of a rounded rectangle but not the radius. If the width of an item gets smaller the radius is automatically adjusted what I don't want. So I want control over the radius.

 

selectedLayer.pageItems[0].width = 30;
 
selectedLayer.pageItem[0].radius = 10 doesn't work
 
Anyone?
TOPICS
Scripting

Views

789

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
Guide ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Is this what you mean by radius?

Untitled.png

Votes

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 ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

Yes

Votes

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
Advocate ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Bonjour,

Appliquer l'effet Convertir en Rectangle arrondi

renl80416020_0-1655287760486.png

 

 

Votes

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
Community Expert ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

Sorry @renél80416020, I didn't see your answer when I posted mine. Yes rounded rectangle might be a better effect to apply, depending on the situation. - Mark

Votes

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
Advocate ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

Merci pour ta remarque bienveillante  M1b.

J'ajouterai que si la demande de Rob186563084tse est de modifier la largeur ou la hauteur d'un rectangle arrondi sans modifier le rayon, voici une ébauche de script.

bissectrice 1.PNG

Bien sur ici je connais la position du point p0.

Un document doit être ouvert.

 

 

var docRef = app.activeDocument;
var obj0 = docRef.pathItems.roundedRectangle(-200, 200, 100, 100, 20, 20, false);
var obj = obj0.duplicate(docRef,ElementPlacement.PLACEATEND);
var nbPt = obj.pathPoints.length;
//Pour un allongement coté gauche
dx = -60;
dy = 0;
       for (var i = 0; i < 4; i++) {
         p = obj.pathPoints[i];
            pointDep (p,dx,dy);
        }

//Pour un allongement coté droit
dx = 30;
dy = 0;
        for (var i = 4; i < nbPt; i++) {
         p = obj.pathPoints[i];
            pointDep (p,dx,dy);
        }
//Pour un allongement coté supérieur
dx = 0;
dy = 10;
        for (var i = 2; i < 6; i++) {
         p = obj.pathPoints[i];
            pointDep (p,dx,dy);
        }
//Pour un allongement coté inférieur
dx = 0;
dy = -10;
        for (var i = 0; i < 2; i++) {
         p = obj.pathPoints[i];
            pointDep (p,dx,dy);
        }
        for (var i = nbPt-2; i < nbPt; i++) {
         p = obj.pathPoints[i];
            pointDep (p,dx,dy);
        }
// -------
function pointDep (p,dx,dy) {
    var pa, pl, pr;
        pa = p.anchor;
        pl = p.leftDirection;
        pr = p.rightDirection;
        p.anchor = [pa[0]+dx,pa[1]+dy];
        p.leftDirection  = [pl[0]+dx,pl[1]+dy];
        p.rightDirection = [pr[0]+dx,pr[1]+dy];
}
// -------

 

 

René

Votes

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 ,
Jun 17, 2022 Jun 17, 2022

Copy link to clipboard

Copied

LATEST

Hi René, I will experiment with your code and let you know if that works. Thanks for your effort. Great. Rob

Votes

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
Community Expert ,
Jun 15, 2022 Jun 15, 2022

Copy link to clipboard

Copied

Hi @Rob186563084tse, sadly we don't have scripting access to the corner radius property of shapes. Only the pathPoints of path items. It could be done in scripting, mathematically, but it would be a chore. Another option might be to apply an Effect > Stylize > Round corners? If your rectangle has that effect, you can scale it (make sure you choose not to scale effects) without changing the corner radius. I realise that might not work in some cases, but just an idea.

- Mark

Screen Shot 2022-06-15 at 9.13.49 pm.png

Votes

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 ,
Jun 16, 2022 Jun 16, 2022

Copy link to clipboard

Copied

Perfect, that works. Thanks!!!

Votes

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