• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Help: Script / Action that re-positions layer to horizontally center on certain X coordinate.

New Here ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

Okay, so I already have a script that resizes my layer correctly, now I need to duplicate it, and the center of each of those two layers needs to end up at 585px and at 2118px.

I recorded an action to duplicate and move, but it is a relative move. The graphic in question is not always the same size, so it ends up in different places sometimes.

What I need to do is reposition the center of each layer to those X coordinates. Or, if we just focus on one at a time, as a test case, I would need to reposition layer one's center to 585px.

I think I have seen in some scripting that you can get the left side coordinate and right side coordinate of your layer. I would imagine we could use those to calculate where the center is, and then use the original position to calculate a relative move to 585?

Any help would be awesome!

TOPICS
Actions and scripting

Views

2.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 14, 2018 Feb 14, 2018

The way you do that in an action is to select that point so you have that single pixel selected. Then you use  two align layer to selection steps to align to the horizontal  and  vertical center of the selection.  The center of that selected pixel. There are 9 alignments possible to that pixel

Votes

Translate

Translate
Adobe
Community Expert ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

UltimatePeter  wrote

I recorded an action to duplicate and move, but it is a relative move. The graphic in question is not always the same size, so it ends up in different places sometimes.

IMO the answer is simple.  It most likely not possible to do what you want to do in an action where things can differ in size.  Actions can use very little logic just test a few conditions.  They can not use  logic to deal with different sizes other to doing some things relative to document size using Photoshop ruler units set to percent.  Other ruler units like inches is relative to document dpi resolution and ruler  pixels is an absolute number of pixels. All steps are hard coded or made interactive.  You need to look into scripting what you want to do. Scripting can use logic to deal with size. Actions can only have some conditional steps.

In an action you can centers a layer center point over a pixel point. But a pixel point has two components not a single value like you write  there is a x and y offset from the document top left corner  0x, 0y point,  So if the layer is the right size and  no mater why its size is you want it center over a point in at document that is alwayr the same size you can do that in an action.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

Thank you for furthering the discussion.

First, it looks like I should have said "y" above. It needs to be at 585 horizontally, on the y axis.

Where would I go to "center a layer center point over a pixel point" ?

In this case, the layer has already been sized appropriately to be the full height of the canvas, so the x will always be consistent.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

The way you do that in an action is to select that point so you have that single pixel selected. Then you use  two align layer to selection steps to align to the horizontal  and  vertical center of the selection.  The center of that selected pixel. There are 9 alignments possible to that pixel

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 14, 2018 Feb 14, 2018

Copy link to clipboard

Copied

LATEST

Thanks, that worked!

Someone is a Guru... It's you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines