Could you please supply a simple example, I dont seem to be able to do this. I thought itd be something like...
var layers=Document.LayeredImage;
Application.MessageBox(layers.Layers(), "", false);
...and it says "layers is not an object or null"
LayeredImage is an interface wrapper accessible as a property of the Document object and can be used to access layers in a layered image. The individual layers can be obtained as standalone documents and other interface wrappers (such as the RasterImage interface) can be used to work with them.
The Context global object can be a used to access the layer currently selected in the editor (available since version 2010.1).
New in version 2010.1:
Could you please supply a simple example, I dont seem to be able to do this. I thought itd be something like...
var layers=Document.LayeredImage;
Application.MessageBox(layers.Layers(), "", false);
...and it says "layers is not an object or null"
Yes, that is the way, although Layers is a property, so it should be layers.Layers
But it won't work, if you are using the script from one of the predefined locations. That is because before these particular scripts are run, the currently selected layer (and frame if you are working with an animation) is already extracted from the whole document and just that single layer is given to the script as its "Document". Without this approach, the scripts would need to contain the code explicitly extract the current frame and/or layer from the Document. I think that would be too much overhead for people starting with scripts.
If you want have a script that gets access to the whole layered image, you'll have to do a bit of configuration. For example like this:
You can give the new button a name and icon of your choice and the Document inside the script will have access to the whole document. That means that typing Document.RasterImage will not work if the document has more than 1 layer - you'll first need to use the GetLayer method to get the layer you want.
That worked a treat!
Thanks heaps for sharing that!
How to create a Layer
Check out this post in the Scripts section....
http://www.rw-designer.com/forum/2709