Align two objects, obj 2 aligned to top and center obj 1
- September 26, 2022
- 1 reply
- 278 views
Hello friends, I have the following code:
var doc = app.activeDocument;
var objeto = doc.selection[0];
var posicion = objeto.position;
var WidthInicial = objeto.width;
var WidthFinal = WidthInicial-14.4;
var ScaleFactor = (WidthFinal / WidthInicial)*100;
objeto.width = WidthFinal;
objeto.resize(100,ScaleFactor, true, true, true, true, null, undefined);
var imgGroup = doc.groupItems.add();
//var rectRef = imgGroup.pathItems.rectangle(posicion[1],posicion[0],objeto.width, objeto.height);
var rectRef = imgGroup.pathItems.rectangle(posicion[1],posicion[0],75,75);
alert(objeto.width + " " + rectRef.width);
//objeto.remove();
//alert("objeto removido");
which gets the width of a selected object, reduces it by 0.2in (14.4px) and also reduces height proportionally, then since it did not scaled to the top center pisition I was trying to create a new square with the new measures, but I can't center the new object (obj 2) to the previous selected object (obj 1).
Can anyone help me please. To make it short I am trying to create a script to reduce a quare/object proportionally in steps of 0.2in and keep it centered in the top center point.

