Skip to main content
runew73276507
Known Participant
December 27, 2015
Answered

Script who moves an already placed frame to a new position (x/y)

  • December 27, 2015
  • 1 reply
  • 2196 views

Hi,

I need help with a simple scriptcode who can move an already placed frame in x=6,99mm /  y=4,801 to a new posistion x=10mm / y=10mm

Can anyone please help?

Merry X-mas!

This topic has been closed for replies.
Correct answer Ronald63

Hi,

Hope this help you :

var doc = app.activeDocument;

var mItems=doc.allPageItems;

var len = mItems.length;

while(len--){

    var mItem = mItems[len];

    var mBounds = mItem.geometricBounds;

    var mX = getRound(mBounds[1],3);

    var mY= getRound(mBounds[0],3);

    if(mX == 6.99 && mY == 4.801){

        mItem.move([10, 10]);

    }

}

/* round */

function getRound(number, digits) {

        digits = (digits) ? Math.pow(10, digits) : 1000; 

        return Math.round(number * digits) / digits; 

}

Regards

1 reply

Ronald63Correct answer
Legend
December 27, 2015

Hi,

Hope this help you :

var doc = app.activeDocument;

var mItems=doc.allPageItems;

var len = mItems.length;

while(len--){

    var mItem = mItems[len];

    var mBounds = mItem.geometricBounds;

    var mX = getRound(mBounds[1],3);

    var mY= getRound(mBounds[0],3);

    if(mX == 6.99 && mY == 4.801){

        mItem.move([10, 10]);

    }

}

/* round */

function getRound(number, digits) {

        digits = (digits) ? Math.pow(10, digits) : 1000; 

        return Math.round(number * digits) / digits; 

}

Regards

runew73276507
Known Participant
December 27, 2015

Thank you so much - you have saved me for at lot of manual work

Ronald63 skrev:

Hi,

Hope this help you :

  1. var doc = app.activeDocument; 
  2. var mItems=doc.allPageItems; 
  3. var len = mItems.length; 
  4.  
  5. while(len--){ 
  6.     var mItem = mItems[len]; 
  7.     var mBounds = mItem.geometricBounds; 
  8.     var mX = getRound(mBounds[1],3); 
  9.     var mY= getRound(mBounds[0],3); 
  10.     if(mX == 6.99 && mY == 4.801){ 
  11.         mItem.move([10, 10]); 
  12.     } 
  13. /* round */ 
  14. function getRound(number, digits) { 
  15.         digits = (digits) ? Math.pow(10, digits) : 1000;   
  16.         return Math.round(number * digits) / digits;   

Regards

Legend
February 2, 2016

What do you mean by this:

"Comment line 6-7-22 and retry ...'


?


Adds // front line ...

// savedUnits = app.scriptPreferences.measurementUnit;