Highlighted

Adjust varying lengths of line at once.

Community Beginner ,
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

Most Valuable Participant
Correct answer by pixxxel_schubser | Most Valuable Participant

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

😉

Topics

How to, Scripting

Views

708

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

Adjust varying lengths of line at once.

Community Beginner ,
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

Most Valuable Participant
Correct answer by pixxxel_schubser | Most Valuable Participant

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

😉

Topics

How to, Scripting

Views

709

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
Adobe Community Professional ,
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

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
Reply
Loading...
Community Beginner ,
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. 

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
Reply
Loading...
Adobe Community Professional ,
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?

 

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
Reply
Loading...
Community Beginner ,
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. 

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
Reply
Loading...
Adobe Community Professional ,
May 02, 2020

Copy link to clipboard

Copied

Maybe someone can write a script to do that.

 

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
Reply
Loading...
Most Valuable Participant ,
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.

 

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
Reply
Loading...
Community Beginner ,
May 03, 2020

Copy link to clipboard

Copied

This does work, 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
Reply
Loading...
Adobe Community Professional ,
May 02, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Most Valuable Participant ,
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

😉

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
Reply
Loading...
Community Beginner ,
May 03, 2020

Copy link to clipboard

Copied

Thank you, this will save me to much time!

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