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

Move layer to cursor

Enthusiast ,
Dec 19, 2015 Dec 19, 2015

Hi, I'm not sure this belongs in the scripting section so maybe I can ask in both this section and the main section.

I'm looking to find a way to move a particular layer to the cursor. SO in other words, imagine you're working on a document with several layers, and you're really zoomed in. I want to be able to select the layer I wish to move by clicking on it in the layers panel, then perhaps run the script (or other method), which will then move that layer in question to wherever the cursor is at that moment. This eliminates the need to zoom way out, click on the layer in the panel, then move it to where I was working, then zoom way back in again. Just imagine that the layer I wish to move contains just a little color dab/pallet thing that I made to sample colors from. I don't want to have to keep zooming out, pull that layer over to where I was zoomed in and then zoom back in again to keep working. I hope this makes sense.

Is there a stock way to do this in photoshop or is it a more complicated (or impossible) thing to do?

Thanks!

TOPICS
Actions and scripting
1.6K
Translate
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
Adobe
Community Expert ,
Dec 19, 2015 Dec 19, 2015

I know of  no way to find out the mouse cursor location in a Photoshop Script.  You can use to color sampler tool to mark up tp 10 location in a Photoshop document.  But I do not think it posible to get the mouse coursor position in a Photoshop script.

You can also set a selection and align layers to the selection. Set guides and align layers to guides

http://www.mouseprints.net/old/dpr/FitImageToGuides.jsx

http://www.mouseprints.net/old/dpr/RotateLayerAbout.jsx

JJMack
Translate
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
Enthusiast ,
Dec 19, 2015 Dec 19, 2015

thanks, JJ. If I could mark the cursor's location with the color sampler tool, would I then be able to move the layer in question to its x,y location?

Translate
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 ,
Dec 20, 2015 Dec 20, 2015

The ColorSamplers’ position can even be evaluated with DOM code, calculating the necessary offset to translate the Layer should not be a problem.

// 2015, use it at your own risk;

#target photoshop

if (app.documents.length > 0) {

var myDocument = app.activeDocument;

var theArray = new Array;

for (var m = 0; m < myDocument.colorSamplers.length; m++) {

theArray.push(myDocument.colorSamplers.position)

};

alert (theArray.join("\n"));

};

Translate
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
Advocate ,
Dec 20, 2015 Dec 20, 2015

Hi,

in case you need more than 10 x/y locations, you can do the same with the Count tool.

Davide

Translate
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
Enthusiast ,
Dec 20, 2015 Dec 20, 2015

thanks guys, yes c.pfaffenbichler, the script returns the x y coordinates of the color sampler point successully. very useful. I also managed to work out another way to do it. It's useful for painters if they want to pull over their little swatch pallet to the exact location they're painting at when zoomed in really close. (not the Swatches Panel, but a manual swatch pallet that they might have sketched out themselves)

1. Ensure the layer you wish to move is the active layer

2. Create any sort of a selection using the lasso tool at the exact area you're working in. Can be any size, anywhere on your document as long as it's close to where you're working.

3. Select the Move Tool.

4. In the options bar, there are now little icons. Click on the "Align Horizontal Centers" icon, and then click on the "Align Vertical Centers" icon. The layer now moves to the selection.

A bit of a task to be honest, but it's a little easier than zooming way out, dragging the layer in question to where you were just working, and then zooming way back in again.

Translate
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 ,
Dec 20, 2015 Dec 20, 2015

1. Ensure the layer you wish to move is the active layer

2. Create any sort of a selection using the lasso tool at the exact area you're working in. Can be any size, anywhere on your document as long as it's close to where you're working.

4. In the options bar, there are now little icons. Click on the "Align Horizontal Centers" icon, and then click on the "Align Vertical Centers" icon. The layer now moves to the selection.

A bit of a task to be honest, but it's a little easier than zooming way out, dragging the layer in question to where you were just working, and then zooming way back in again.

Its 1 target layers to be aligned, 2 make a selection to align the layers to  and 4 the two align steps. 3 the move tool is not required.   And 4 is a simple key press. You just need to record the two align steps into an action and assign a shortcut like F2 to the action.

Step 1 menu Layer>Align Layers to Selection>Vertical Center

Step 2 menu Layer>Align Layers to Selection>Horizontal Center

JJMack
Translate
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
Enthusiast ,
Dec 20, 2015 Dec 20, 2015
LATEST

Awesome!! Thanks JJ! I thought we had to select the move tool for it to work. Now that it's unnecssary, everything is running even better. It's an extra step we didn't need

Translate
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