Skip to main content
February 12, 2018
Answered

Move 1 pica

  • February 12, 2018
  • 2 replies
  • 1208 views

Trying to come up with a script that moves a selected page item (text frame, graphic frame, etc), or many page items (eventually), 1 pica to the right (to start, will eventually have many scripts attached to keyboard shortcut for every direction)?

The below script is what I have so far. You would think it would be straight forward, but with everything I’ve read I’m left scratching my head on this one.

Any help is very much appreciated. Cheers.

var myPageItem = app.activeDocument.selection[0];

myPageItem.TransformationMatrix.translateMatrix.properties = {

   

    horizontalTranslation:("1p"),

    verticalTranslation:(0),

   

    };

This topic has been closed for replies.
Correct answer Laubender

Hi Neal,

why not using method move() ?

move() for a selected page item has two arguments:

to and by

You'd need the second one, the by argument.

The trick here is to declare the first one as undefined.

app.selection[0].move( undefined , [ "1p" , 0 ] );

Regards,
Uwe

2 replies

Stefan Rakete
Inspiring
February 12, 2018

   Hi,

     here is the version with the transformation matrix:

    var curSel = app.selection[0];

    var myTransformationMatrix = app.transformationMatrices.add();

    // translateMatrix takes two parameters: horizontallyBy and verticallyBy

    myTransformationMatrix = myTransformationMatrix.translateMatrix(72, 0);

    curSel.transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.centerAnchor, myTransformationMatrix);

You need to convert from pica to points I believe.

Thanks Stefan

Community Expert
February 12, 2018

https://forums.adobe.com/people/Stefan+Rakete  wrote

… You need to convert from pica to points I believe.

Thanks Stefan

Hi Stefan,

absolutely.

The problem may be that you cannot use UnitValue for this.

And how many Points go into one Pica? ( 12 )
How to deal with expressions like "1p7" ?

I'm not at all familiar with using Picas, but this should work:

var xAsPicas = "1p7";

var xInPoints = Number( xAsPicas.split("p")[0] )*12 + Number( xAsPicas.split("p")[1] );

Regards,

Uwe

LaubenderCommunity ExpertCorrect answer
Community Expert
February 12, 2018

Hi Neal,

why not using method move() ?

move() for a selected page item has two arguments:

to and by

You'd need the second one, the by argument.

The trick here is to declare the first one as undefined.

app.selection[0].move( undefined , [ "1p" , 0 ] );

Regards,
Uwe

February 12, 2018

Nice. I started out using move, but didn’t understand the “to” and “by” parameters [?] array format.

This is great, now I have these moves at my finger tips and no longer need to rely on the Transform > Move command.

I regularly have situations where I jump specifically by either a pica or by 9 pt increments (screenshot below).

This is awesome.

Thanks again.