Skip to main content
Inspiring
February 1, 2023
Question

Reduce Vertical Size

  • February 1, 2023
  • 3 replies
  • 551 views

Hi

 

Script Illutrator where select all objects and reduce 6,34 milimeters vertical size, but not work...

 

var doc = app.activeDocument;
var widthReduction = 6.34;

widthReduction = widthReduction / 25.4 * 72; // convert mm to points

for (var i = 0; i < doc.layers.length; i++) {
var layer = doc.layers[i];
for (var j = 0; j < layer.pageItems.length; j++) {
var item = layer.pageItems[j];
item.selected = true;
}
}

var sel = doc.selection;
for (var i = 0; i < sel.length; i++) {
sel[i].width -= widthReduction;
}

 

 

This topic has been closed for replies.

3 replies

renél80416020
Inspiring
February 12, 2023

Bonjour,

Essayez avec cela...

// JavaScript Document
var center = true;
var doc = app.activeDocument;
var widthReduction = 6.34;  // mm
    widthReduction = widthReduction / 25.4 * 72; // convert mm to points
    if (selection.length)
      for (var i = 0; i < selection.length; i++) {
        reduc(selection[i]);
      }
    else
      for (var i = 0; i < doc.pageItems.length; i++) {
        var item = doc.pageItems[i];
            if (!item.layer.locked) {reduc(item)}
      }
function reduc(obj) {
  if (obj.width > widthReduction) {
    obj.width -= widthReduction;
    if (center) {obj.left += widthReduction/2;}
  }
}

René

Inspiring
February 16, 2023

Hi @renél80416020 

 

The reduce is weight... sorry.. How ?

Met1
Legend
February 2, 2023

"Reduce Vertical Size" 

"var widthReduction"

Sure you have the right paramenter in there?

femkeblanco
Legend
February 1, 2023

Works as expected (reducing width).  How is it not working for you?  (Does nothing happen?  Do you get an unexpected result?  Do you get an error?  Et cetera.)