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

script to "convert anchor points to corner/smooth"

Contributor ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

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...

TOPICS
Scripting

Views

864

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

correct answers 1 Correct answer

Enthusiast , Nov 14, 2023 Nov 14, 2023

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

Votes

Translate

Translate
Adobe
Enthusiast ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

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

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 ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

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

 

Screenshot 2023-11-15 at 16.25.48.pngexpand image

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 ,
Nov 14, 2023 Nov 14, 2023

Copy link to clipboard

Copied

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

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
Enthusiast ,
Nov 15, 2023 Nov 15, 2023

Copy link to clipboard

Copied

I'm weak in the mathematics of Bezier curves. But Jim's solution is interesting. And I have seen the use of the Catmull-Rom spline more than once in the scripts of Japanese authors.

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 ,
Nov 25, 2023 Nov 25, 2023

Copy link to clipboard

Copied

Bonjour à tous,

En 2013, j'ai publié un script "arrondi_angle1.js" sur Scriptopedia.org

A l'époque le script GenerateHandles.js de Hiroyuki  ne me convenait pas entièrement, c'est pourquoi j'ai étudié le problème et faire à mon idée.

Dont voici le lien. https://www.scriptopedia.org/js-illustrator/162-arrondir-les-angles.html

Je suis juste intervenu pour vérifier si je pouvais encore me connecter, j'ai corriger une faute de grammaire dans le texte, ce qui explique la mise à jour 2023 qui n'en est pas vraiment une.
le script est de l'époque de la CS2, j'ai fait quelques progrès depuis.

Il fonctionne de deux manières:
A un ratio variant de 0 à 1.

B En fixant la longueur des lignes directrices en points (toutes le lignes auront la même longueur).

Vous pouvez passer d'un mode à l'autre en modifiant dans la zone init du script la variable fixe = true ou false

René

PS Je peux éventuellement améliorer l'interface avec une boîte de dialogue.

Me le demander par mail.

Exemples:

Tracé d’origine en position centrale (échelle réduite)
composé de 24 points

round1.PNGexpand image

round2.PNGexpand image

Option fixe permet de faire en sorte que la longueur des lignes directrices de gauche de droite
soient de même longueur (donnée en pt)

round3.PNGexpand image

round4.PNGexpand image

On peut également demander à ne pas traiter les extrémités des tracés ouverts.

round5.PNGexpand image

 

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 ,
Nov 25, 2023 Nov 25, 2023

Copy link to clipboard

Copied

Beautiful, René.

 

Thanks for contributing.

 

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 ,
Nov 25, 2023 Nov 25, 2023

Copy link to clipboard

Copied

LATEST

Wonderful script, @renél80416020! Thanks for sharing.

- 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
Contributor ,
Nov 15, 2023 Nov 15, 2023

Copy link to clipboard

Copied

wow, Sergey, thanks so much for the link to Jim Heck's script!

I had already looked at Hiroyuki's script, which is awesome but not quite what I needed.

I had started doodling with something along the same lines of Jims approach but got pretty overwhelmed by the maths.

 

I am constantly amazed by the generosity of these script writers, to share their work and also to annotate thier code so clearly for lowly mortals like myself... when the interent actually does something good, huzzah

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
Enthusiast ,
Nov 15, 2023 Nov 15, 2023

Copy link to clipboard

Copied

I support what you say. One of the users of my scripts said to me: "People who give these little useful things away for free are the fading heartbeat of the internet". And those were important words.

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