Skip to main content
Inspiring
November 15, 2023
Answered

script to "convert anchor points to corner/smooth"

  • November 15, 2023
  • 1 reply
  • 1609 views

hi

 

I'm writing a script to clean up some imported line drawings and would really like emulate the behaviour of clicking the convert anchor point buttons in the UI. I haven't been able to find a way to do it.


My workflow is basically to select the anchorpoints that need smoothing, click the "convert to corner", which contracts all the bezier handles, then click "convert to smooth" which automatically adds nicely balanced handles with smooth curves between anchors. For my use case this actually works much better than trying to apply 'smoothing'

 

Simply changing the pathPoint type to PointType.CORNER and then to PointType.SMOOTH doesn't do the job.

And I can't find the button functionality as a menu item so I can go that way either.

 

Any suggestions greatly appreciated...

This topic has been closed for replies.
Correct answer Sergey Osokin

Look at these scripts:
1) Smooth Curve Points by Jim Heck
2) Smoothing by Hiroyuki Sato

1 reply

Sergey Osokin
Sergey OsokinCorrect answer
Inspiring
November 15, 2023

Look at these scripts:
1) Smooth Curve Points by Jim Heck
2) Smoothing by Hiroyuki Sato

m1b
Community Expert
Community Expert
November 15, 2023

These are great @Sergey Osokin. I did a quick test and found the Jim Heck's script matches the UI's behaviour more closely.  - Mark

 

m1b
Community Expert
Community Expert
November 15, 2023

Hiroyuki's and Jim's scripts are totally different. The smoothing.jsx script calculates a catmull-rom spline (which is where my mind went, too) and converts to beziers, but the smoothingCurvePoints.jsx script is simply about angles and sizes and scale (25%), with really no bezier maths at all. I'm no expert but I found it quite fascinating!

- Mark