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

Scaling objects along a direction

Participant ,
Feb 22, 2024 Feb 22, 2024

Copy link to clipboard

Copied

I am looking to achieve this result with a group or many items. The scaling should happen along a direction and if possible radial too. The objects can be randomly arranged too. I need the scaling to follow from high to low.

StarAG_0-1708615431918.png

 

TOPICS
Draw and design , Experiment , Feature request , How-to , Scripting , Third party plugins

Views

245

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
Adobe
Advocate ,
Feb 22, 2024 Feb 22, 2024

Copy link to clipboard

Copied

Bonjour,

Essayez cela.

 

// JavaScript Document for illustrator
// reduire via direction
// Auteur Landry René
 function main() {
  var item, pathes = [];
      extractPathes(selection,pathes);
        if (pathes.length == 0) {
          alert("Une sélection est obligatoire ?");
          return;
        }
  var pos = [];
      for (var h = 0; h < pathes.length; h++) {
        item = pathes[h];
          pos.push([item.top-item.height/2,pathes[h]])
        }
      pos.sort(function (a, b) { return a[0]-b[0]} )
  var nbr = 0;
  var top0 = pos[0][0];
        do {
           nbr++;
        } 
        while (pos[nbr][0] > top0-5 && pos[nbr][0]< top0+5)
                 
  var nbl = pos.length/nbr;
  var ecart = 100/(nbl+1);
      //alert( pos.join("\r"))         
  var r = 100-ecart; 
  var top0 = pos[nbr-1][0];
  
        for(var h = nbr, c = 0; h < pos.length; h++) {
            top = pos[h][0];
              if (pos[h][0] > top0+5) {
                  pos[h][1].resize(r,r);
                  c++;
              }
             if (c == nbr) {top0 = pos[h][0]; r -= ecart; c = 0;}   
        }
}       
main();
// --------
function extractPathes(s, tabs){
  for(var i = 0; i < s.length; i++){
    if(s[i].typename == "PathItem" && !s[i].guides && !s[i].clipping){
      tabs.push(s[i]);
    } else if(s[i].typename == "GroupItem"){
      // Cherche les objets de types pageItems dans ce groupe, recursivement
      extractPathes(s[i].pageItems, tabs);
    } else if(s[i].typename == "CompoundPathItem"){
      // Cherche les objets de type PathItem dans ce trace transparent, recursivement
      extractPathes(s[i].pathItems, tabs);
    }
  }
}
// --------

 

 

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 ,
Feb 22, 2024 Feb 22, 2024

Copy link to clipboard

Copied

That works very well, René.

 

Thanks for sharing.

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
Participant ,
Feb 22, 2024 Feb 22, 2024

Copy link to clipboard

Copied

This works with well arranged object.

I applied random positions to my object and it didn't worked. See Test.ai file https://t.ly/Tnv0z

 

Can we also get a gradient annotator style tool for this so that I can scale it as per my direction. Further if there is a scale intensity option too, it will be great.

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 ,
Feb 23, 2024 Feb 23, 2024

Copy link to clipboard

Copied

LATEST

Bonjour StartAG

Le script fonctionne avec de objets alignés horizontalement avec une tolérance de +- 5pt,

désolé, je pensais que votre exemple correspondait à ça (je l'ai édité spécialement pour l'occasion).

Je constate que vous êtes assez exigeant.

René

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