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.
Copy link to clipboard
Copied
Is this what you mean by radius?
Copy link to clipboard
Copied
Yes
Copy link to clipboard
Copied
Bonjour,
Appliquer l'effet Convertir en Rectangle arrondi
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
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.
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é
Copy link to clipboard
Copied
Hi René, I will experiment with your code and let you know if that works. Thanks for your effort. Great. Rob
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
Copy link to clipboard
Copied
Perfect, that works. Thanks!!!