Skip to main content
cc_user_o
Participant
February 3, 2022
Question

Round corner radius from JS script?

  • February 3, 2022
  • 2 replies
  • 2973 views

Dear AI community

 

I'm struggling with automating a batch job which involves rounding all corners (including sharp ones, low  angle) in a PathItem.

 

I need to replicate from the script what you can do manually by selecting all anchor points and either dragging the round corner handler or just setting the corner radius under object Properties pane -> Corners field. 

 

I spent a reasonable amount of time digging AI scripting guide and seems can't find anything related to rounding PathItem.pathPoints elements. Can't find any equivalent API to setting the corner radius via UI Properties->Corners field. 

 

Also another issue is the corner radius handle & property will only show when the corner angle is bigger than certain threshold. Not sure why. Other vetcor editors I tried e.g. Inkscape or Affinity Designer don't have this limitation, you can round literraly any corner and it works rather well. Is there any way to force round corner regadless of angle? Changing the geometry slightly just to get over the corner angle threshold to get access to the radius property is not going to work for me. This is an automated batch job with a lot of geometry to process.

 

Any advice please? 

 

What I tried so far:

 

Tried the built in Round Corner filter you can apply to any object via effects property. Unfortunatelly it is far not the same as rounding corners directly via anchor Radius property in editor quality wise. The Round Corners filter will mess up corners where the sides are not stright lines but curved beziers. Changing radius property for the same corner directly in editor doesn't do that and works as expected.

 

I've managet to google up this rather advanced Round Corners AI script by WELZ-gh. It is a serious amount of code but unfortunately it doesn't quite work correctly. Multiple similar corners will get different inconsitent amount of rounding and also the rounding itself for many corners looks way too sharp. 

https://gist.github.com/WELZ-gh/fcbf311cf504a001577d8d424336e592

2 replies

Participant
July 16, 2025

divide the angle into two support points use bezier levers on these points they always look opposite to the sides of the angle and the extension of the levers is calculated mathematically using the formula on the Internet

 

renél80416020
Inspiring
February 3, 2022

Bonjour,

Peut-être de ce coté là ?

https://community.adobe.com/t5/illustrator-discussions/need-help-rounded-corners/m-p/11182904

Si le lien est correct...

René

cc_user_o
cc_user_oAuthor
Participant
February 3, 2022

 

Thanks René.

 

Been there, seen that. Unless I'm missing something I don't think there is a universal ready to use solution in that thread. Unfortunately I'm not a maths ninja to replicate what the available via AI UI built in corner rounding function does in the script. This would too much for me to handle 😞

 

So I'm hoping may be there is a way to simply invoke UI from script to do the same? i.e. iterate through PathItem points. Select one at a time. Then somehow call into UI to do the corenr rounding bit? Any other options perhaps?

 

Thanks

renél80416020
Inspiring
February 3, 2022

J'aimerais bien avoir un exemple de ce que vous souhaitez pour mieux comprendre.

Mon script fait cela, mais je peux le modifier...

René