Skip to main content
Participant
November 26, 2018
Answered

selecting "pathItems" by Height, and changing to a specific height

  • November 26, 2018
  • 3 replies
  • 654 views

Hi, looking for a little HELP here.

I have a file with a Barcode which I need to resize. In this Barcode, there's two different groups of path heights, a taller one and a shorter one.

I've written a code, to identify these bars according to their height value, and then resize them to another specific value.

var Small = app.activeDocument.pathItems;

for (h=0;h<Small.length;h++){

var SmallGroup = Small;

if (SmallGroup.height < 25){

SmallGroup.height = 14.943;

} else {

SmallGroup.height = 18.647;

}

}

These bars should look like this, if the code worked correctly, (please disregard color formatting and font change, I've already solved that):

However, I get an error message:

Once I hit "OK" to dismiss the error, the height changes get applied, but the rest of code/actions does not run.

and no matter what I do, I always get an error regarding the "height"

so I'm guessing this has something to do with the height property, but I'm not able to figure it out.

If anyone knows a different approach or understands javascript better, please let me know.

thanks!!!!

This topic has been closed for replies.
Correct answer CarlosCanto

perhaps there are other pathItems in the document? other than the barcode lines? what are those magenta lines?

if you try to give height to a horizontal line, it will raise an error.

3 replies

dvivasAuthor
Participant
November 27, 2018

I think Carlos got it right, once I got rid of the guidelines, the script worked perfectly.

Thank you for your responses!! really helpful!!!

Thanks!

Inspiring
November 27, 2018

Можно поступить иначе:

   //1. create shape >>>>

        app.executeMenuCommand("selectall"); 

        app.executeMenuCommand('group');

        app.executeMenuCommand("Live Pathfinder Crop"); 

        app.executeMenuCommand("expandStyle"); 

ScooterD76
Legend
November 26, 2018

I know nil about scripting, is there a reason you cant just select the points along the top and resize them manually?

CarlosCanto
Community Expert
CarlosCantoCommunity ExpertCorrect answer
Community Expert
November 27, 2018

perhaps there are other pathItems in the document? other than the barcode lines? what are those magenta lines?

if you try to give height to a horizontal line, it will raise an error.