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

Move paths to anchor points

Contributor ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

Hi,

I want to move each one of selected paths to anchor points

From this

To this

siomosp_0-1668072860067.jpeg

 

It is possible via script?


This old script duplicates one selection to all anchors, I need something similar

https://github.com/Shanfan/Illustrator-Scripts-Archive/blob/master/jsx/Dup%20At%20Selected%20Anchors... 

 

TOPICS
Scripting

Views

170

Likes

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

Advocate , Nov 11, 2022 Nov 11, 2022

Bonjour,

/*Duplicates each element of the group placed in the foreground
to center them on selected points within paths or isolated points.
Duplicates each element of the group placed in the foreground on each of the selected points*/

// JavaScript Document
/* Duplique chaque élément du groupe placé au premier plan
   pour les centrer sur les points sélectionnés appartenant à des tracés ou des points isolés.*/
function main(){
  var doc = activeDocument;
  var s = selection;
    if (s.length < 2) re
...

Likes

Translate

Translate
Advisor ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

It should be possible.  Are the crosses in the middle of the banners points or paths?  Can you show the fully expanded layers panel?  

Likes

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 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

Hello!

The crosses are paths

Likes

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 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

If you draw single points as markers for object positions, the script is easier to write. 
ezgif.com-gif-maker.gif

Another script variant is to draw a path with anchor points, place it at the bottom or at the top of the selection, and place the other objects along the points of this key path. 

ezgif.com-gif-maker (1).gif

Likes

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
Advisor ,
Nov 10, 2022 Nov 10, 2022

Copy link to clipboard

Copied

Another unclear thing is whether the OP really means to move "paths" and not textframe characters. 

Likes

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 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

Hi, the path is outlined text, not textframe characters.
Thank you!

Likes

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 11, 2022 Nov 11, 2022

Copy link to clipboard

Copied

Bonjour,

/*Duplicates each element of the group placed in the foreground
to center them on selected points within paths or isolated points.
Duplicates each element of the group placed in the foreground on each of the selected points*/

// JavaScript Document
/* Duplique chaque élément du groupe placé au premier plan
   pour les centrer sur les points sélectionnés appartenant à des tracés ou des points isolés.*/
function main(){
  var doc = activeDocument;
  var s = selection;
    if (s.length < 2) return;
  var gr = s[0]; // Groupe premier plan
      if (gr.typename != "GroupItem") return;
  var nbObj = gr.pageItems.length,
      paths = [];
      extractPathes(s.slice(1), paths, 0);
  var pts, tgt_point, vb;

    for(var i = 0, k = 0; i < paths.length; i++){
      pts = paths[i].pathPoints;
        for(var j = 0; j < pts.length; j++) {
          if(isSelected(pts[j])) {
            if (nbObj == k) break;
              tgt_item = gr.pageItems[k];
              vb = tgt_item.visibleBounds;
              tgt_point = [(vb[0]+vb[2])/2,(vb[1]+vb[3])/2];
              tgt_item.duplicate(paths[i],ElementPlacement.PLACEBEFORE).translate(
                  pts[j].anchor[0]-tgt_point[0],
                  pts[j].anchor[1]-tgt_point[1]);
              k++;
            }
        }
    }
}
// -------
function isSelected(pt){return pt.selected == PathPointSelection.ANCHORPOINT;}
// -------
function extractPathes(s,tabs,deb){
  for (var i = 0; i < s.length; i++){
    if(s[i].typename == "PathItem" && !s[i].guides && !s[i].clipping && i >= deb){
      tabs.push(s[i]);
    } else if(s[i].typename == "GroupItem"  && i >= deb){
      // Cherche les objets pageItems dans ce groupe, récursivement
      extractPathes(s[i].pageItems,tabs,0);
    } else if(s[i].typename == "CompoundPathItem" && i >= deb){
      // Cherche les objets de type PathItem dans ce tracé transparent, récursivement
      extractPathes(s[i].pathItems,tabs,0);
    }
  }
}
// -------
if (app.documents.length > 0) main();

René

Capture.PNG

Likes

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 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

Hello @femkeblanco, thank you for the script, it's working great !!!!

Thanks a lot!

Recording #2.gif

Likes

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
Advisor ,
Nov 12, 2022 Nov 12, 2022

Copy link to clipboard

Copied

LATEST

I'm happy to take the credit, but it was @renél80416020's script. 

Likes

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