Copy link to clipboard
Copied
How to reference/access the copied layer in extendscript?
Copy link to clipboard
Copied
What copied layer? How is it even copied and what do you want to do with it? You need to explain better.
Mylenium
Copy link to clipboard
Copied
I want to copy a layer and then run my script, so that in my script I access the copied layer, like paste command pastes the copied layer.
Copy link to clipboard
Copied
I think there is no easy way to access copied layer data from the clipboard with an Ae script.
Copy link to clipboard
Copied
Do you mean you want your script to access a layer that's been copied to the clipboard with Edit > Copy ? I don't know of any way to do that other than to maybe paste it temporarlily and then delete that layer when you're done--but what's your ultimate objective?
Copy link to clipboard
Copied
Yes you got it. I want my script to write expression to the selected layers, in which it will have reference to the copied layer. Yes the pasting temporarily and deleting after I'm done is a way, I thought it, just wanted to know if there were shorter way, thank you
Copy link to clipboard
Copied
I don't know if this helps, but selectedLayers are in the array in the order that you select them, so maybe your work flow could be (instead of copying the reference layer) to first select the reference layer, and then select the layers that recieve the expression. Then selectedLayers[0] would always be the reference layer.
Copy link to clipboard
Copied
In my script CopyMask2Layer I had a similar situation, where I wanted to copy masks from one layer and then paste it to all selected layers. I solved it by using two buttons in the script. If you want to do it that way, you could have one button "choose reference layer" and one "apply expression". When the user clicks the button "choose reference layer", you check which layer is selected and save the expressions code to link to that layer in a variable. When the user then clicks the "apply expression" button, the script uses the content from that variable in the expressions it generates.
In other words, instead of relying on the normal copy/paste, you create your own copy (or "choose reference layer") button and instead of saving the copied layer in the clipboard, you use a variable.
Copy link to clipboard
Copied
Thank you all
Copy link to clipboard
Copied
Here is what I wanted. But haaven't tried yet.
Copy link to clipboard
Copied
I don't think a layer will actually end up in the clipboard. You could get keyframe data as text that way, but that won't even identify the layer it came from. I don't think it will do what you want, but I'd love to be surprised.
Copy link to clipboard
Copied
the copied text content is sufficient for my needs. However if not, another solution is to copy the reference (ctrl+alt+c) of a layer property, if you paste it into some text editing area, you will see the reference to the layer in the text data. like comp("name").layer("name").transform.position for example.
Copy link to clipboard
Copied
Your method to retrieve clipboard data can only retrieve text, in the same way as if you try to paste the clipboard to a text editor.
If you copy a layer in Ae and paste it into a text editor the result looks like this:
After Effects must have keyframes selected from one layer in order to export them as text.
If you select a property of a layer and do ctrl+alt+c, the pasted content looks somewhat like this:
Adobe After Effects 8.0 Keyframe Data
Units Per Second 25
Source Width 1920
Source Height 1920
Source Pixel Aspect Ratio 1
Comp Pixel Aspect Ratio 1
Transform Position
Frame X pixels Y pixels Z pixels
960 960 0
Expression Data
comp("Comp 1").layer("Dark Red Solid 1").transform.position
End of Expression Data
End of Keyframe Data
So in principle, you could take the line
comp("Comp 1").layer("Dark Red Solid 1").transform.position
from that text to fgure out which layer of which comp was copied.
However, if the selected property has an expression applied to that, you will have that expression in the data instead. Hence, it is not really a reliable workaround.
Copy link to clipboard
Copied
Thanks