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

Adjust varying lengths of line at once.

Community Beginner ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

I am working on a project with topographic lines. Each line has varying space between them but they all increase by a height of 20mm (after I'm done they're vertically aligned to the bottom of the artboard). The lines on the left are an example of the ones that have been completed. Is there a way I adjust the length of all the lines at once with a constant increase in length?

Thanks!

illustrator.png

TOPICS
Scripting

Views

1.1K

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 2 Correct answers

Community Expert , May 02, 2020 May 02, 2020

wyatts,

 

Can you reverse the order of how you build the lines?

 

As far as I can see you create short lines and distribute them at varying distances, and then you wish to increase their lengths linearly.

 

If you can create them at different lengths and then place them at varying distances, it is much easier because you can start by create lines at linearly increasing lengths with a simple Blend, expand the Blend, and then distribute the lines as desired.

 

Votes

Translate

Translate
Community Expert , May 03, 2020 May 03, 2020

Hi @wyatts93859812,

do you mean something like that?

 

The main "problem" is the basic structure of the script. Ultimately, only two loops are required:

 

// https://community.adobe.com/t5/illustrator/adjust-varying-lengths-of-line-at-once/td-p/11099361?page=1
// resize_increase_height_based_on_xPosition.jsx
// regard pixxxelschubser  03. März 2020

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...

Votes

Translate

Translate
Adobe
Community Expert ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

If they are not grouped you could try Object > Transform > Transform Each and scale them vertical with Scale Strokes & Effects unchecked

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 Beginner ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

I tried your idea. I don't think it works since it scales them all the same. 

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 ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

They scale with a percentage of their original size, so maybe I misunderstood

Do I understand correctly that you want to add a fixed size to different size lines?

 

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 Beginner ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

My bad. The length of the line would go like 20mm for the first, 40mm for the second, 60mm for the third, and so forth until it reaches the last line. 

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 ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

Maybe someone can write a script to do that.

 

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 ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

wyatts,

 

Can you reverse the order of how you build the lines?

 

As far as I can see you create short lines and distribute them at varying distances, and then you wish to increase their lengths linearly.

 

If you can create them at different lengths and then place them at varying distances, it is much easier because you can start by create lines at linearly increasing lengths with a simple Blend, expand the Blend, and then distribute the lines as desired.

 

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 Beginner ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

This does work, thank you!

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 ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

it could be scripted, I'm not sure what the requirement is.

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

Hi @wyatts93859812,

do you mean something like that?

 

The main "problem" is the basic structure of the script. Ultimately, only two loops are required:

 

// https://community.adobe.com/t5/illustrator/adjust-varying-lengths-of-line-at-once/td-p/11099361?page=1
// resize_increase_height_based_on_xPosition.jsx
// regard pixxxelschubser  03. März 2020

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// required: opened document, only lines with the same height on the active layer //
// all paths are ungrouped and simple paths (lines)                                                      //
// no selection needed                                                                                                        //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

main();
app.redraw();
alert("Done");

function main() {
var aDoc = app.activeDocument;
var Pths = aDoc.activeLayer.pathItems;
var len = Pths.length;
var list = new Array ();
var toMM = 2.83464567;
var Pth, item, factor, inc;

inc = prompt ("Please enter the value of increment (mm)", 2, "Increment");
if (inc == null) { return; }
if (inc.match(/[0-9]+/) == null) { return;}
inc = inc*1;

for (i = 0; i < len; i++) {
    Pth = new Array (2);
    Pth[0] = Pths[i].left;
    Pth[1] = Pths[i];
    list.push(Pth);
    }

list.sort();

for (k = len-1; k >= 0 ; k--) {
    item = list[k][1];
    factor = (item.height +inc*toMM*k)*100/item.height;    
    list[k][1].resize( 100, factor, true, true, true, true, 100, Transformation.CENTER );
    }
};

 

 

Before:

resize_by_xPosition_01.png

During:

resize_by_xPosition_02.png

Result:

resize_by_xPosition_03.png

 

If that works for you

have fun

😉

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 Beginner ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

Thank you, this will save me to much time!

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 ,
May 03, 2020 May 03, 2020

Copy link to clipboard

Copied

LATEST

For my part you are welcome, Wyatt.

 

Scripts are almost always easier (for the lucky one that can use it without having to create it).

 

We are very lucky to have scripter friends, such as Hans-Jürgen and Carlos.

 

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