How are individual layers from a .PSD defined in ASP11?
Moderators: Víctor Paredes, Belgarath, slowtiger
How are individual layers from a .PSD defined in ASP11?
How are individual layers from a photoshop file defined in ASP11?
In ASP10 It used to be something like this:
Example.psd *5
(Layer 5 from Example.psd)
How is it done since v11? What has changed exactly? We used to have use a script to exchange layer sources but it is broken now and we're on a quite tight deadline.
In ASP10 It used to be something like this:
Example.psd *5
(Layer 5 from Example.psd)
How is it done since v11? What has changed exactly? We used to have use a script to exchange layer sources but it is broken now and we're on a quite tight deadline.
- Víctor Paredes
- Site Admin
- Posts: 5661
- Joined: Wed Jan 26, 2005 12:18 am
- Location: Barcelona/Chile
- Contact:
Re: How are individual layers from a .PSD defined in ASP11?
Hi Lukas,
I have a question: Is this a script to modify the text of an AS file, or a Lua script to run in the application to set a new image layer source?
I have a question: Is this a script to modify the text of an AS file, or a Lua script to run in the application to set a new image layer source?
Moho Product Manager
www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
-
- Posts: 303
- Joined: Thu May 13, 2010 2:01 pm
Re: How are individual layers from a .PSD defined in ASP11?
Hi Victor. It's the latter: a lua menu script to switch sourceimages. We have a PSD in which we have the character cut up. When we design a new character to that template, we run the script to replace all the images. It used to work in ASP10 where all the PSD layers were replaced with the corresponding layers of the new design. But since APS11 it doesn't work anymore and every layer is replaced with a full composite of the PSD, so all the layers merged together. I think the problem is with how ASP marks a PSD layer.
Can you help?
Can you help?
- Víctor Paredes
- Site Admin
- Posts: 5661
- Joined: Wed Jan 26, 2005 12:18 am
- Location: Barcelona/Chile
- Contact:
Re: How are individual layers from a .PSD defined in ASP11?
Hi Lukas and Breinmeester, here's an answer from Mike Clifton:
"OK, so here’s what I can tell you:
In a PSD file, each layer has a unique ID. That ID will never get used twice in the same PSD file. In the past, AS referenced PSD layers from bottom to top: 0, 1, 2, 3, etc. But starting in AS 11, we reference PSD layers by this unique ID instead. Then benefit of this is that if you add new layers or re-arrange layers in the PSD file, we can still find the same layer by its unique ID, so changing layer arrangements in Photoshop doesn’t mess up Anime Studio. With the old method, changing layers in the PSD file would just mess things up in AS.
So that’s the background, now on to the issue. In AS 11, you can still use the same notation for assigning a layer. For example, this Lua code is still valid - it will assign layer 3 of a PSD file to the given image layer. I’m seeing just this PSD particular layer appear in the AS image layer as expected:
imageLayer:SetSourceImage(“/Document/Path/MyImage.psd*3*”)
But here’s the difference: You can assign a layer that way, but then internally, AS gets the unique ID that is inside the PSD file, and it remembers that. It forgets about the *3* notation because that’s not necessarily permanently valid, but the unique ID is. So later, if you call this Lua function:
print(imageLayer:SourceImage())
The result will be: /Document/Path/MyImage.psd without the *3* notation.
AS11 can still use the *3* notation for loading a file, but it no longer stores this internally.
I hope that helps."
"OK, so here’s what I can tell you:
In a PSD file, each layer has a unique ID. That ID will never get used twice in the same PSD file. In the past, AS referenced PSD layers from bottom to top: 0, 1, 2, 3, etc. But starting in AS 11, we reference PSD layers by this unique ID instead. Then benefit of this is that if you add new layers or re-arrange layers in the PSD file, we can still find the same layer by its unique ID, so changing layer arrangements in Photoshop doesn’t mess up Anime Studio. With the old method, changing layers in the PSD file would just mess things up in AS.
So that’s the background, now on to the issue. In AS 11, you can still use the same notation for assigning a layer. For example, this Lua code is still valid - it will assign layer 3 of a PSD file to the given image layer. I’m seeing just this PSD particular layer appear in the AS image layer as expected:
imageLayer:SetSourceImage(“/Document/Path/MyImage.psd*3*”)
But here’s the difference: You can assign a layer that way, but then internally, AS gets the unique ID that is inside the PSD file, and it remembers that. It forgets about the *3* notation because that’s not necessarily permanently valid, but the unique ID is. So later, if you call this Lua function:
print(imageLayer:SourceImage())
The result will be: /Document/Path/MyImage.psd without the *3* notation.
AS11 can still use the *3* notation for loading a file, but it no longer stores this internally.
I hope that helps."
Moho Product Manager
www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
-
- Posts: 303
- Joined: Thu May 13, 2010 2:01 pm
Re: How are individual layers from a .PSD defined in ASP11?
Ok, so there's the problem, because my script calls the sourceimage path using: imageLayer:SourceImage()
Then it looks for the '*' and parces out the LayerID to append it to the new path to call for the right layer in the new PSD file.
How can i call for the PSD layer ID of the sourceimage used in a layer in APS11?
Then it looks for the '*' and parces out the LayerID to append it to the new path to call for the right layer in the new PSD file.
How can i call for the PSD layer ID of the sourceimage used in a layer in APS11?
- synthsin75
- Posts: 9973
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: How are individual layers from a .PSD defined in ASP11?
The only way I can think of, offhand, is to parse the PSD for layer IDs, but maybe AS stores the layer IDs as metadata. You'd need to look at the unzipped anime file to see.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: How are individual layers from a .PSD defined in ASP11?
The best solution would be to ask the developers to add PSD layer numbering control to the Lua API. It shouldn't be too hard for them.
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
- synthsin75
- Posts: 9973
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: How are individual layers from a .PSD defined in ASP11?
Just checked, and metadata does give you the psd IDs in AS layer ordering notation under the metadata key "psd_layers". It would be fairly simple to parse that metadata key's value for psd layer IDs and matching AS layer order, but I'm not sure about how to you'd get the matching psd layer order. The info is in the anime file, but you have to unzip it first and it's not easy to parse in its no-whitespace form.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: How are individual layers from a .PSD defined in ASP11?
Thanks for the info synthsin75.
I have unzipped the anime file, and browsed the json content of the .animeproj fileand there I found the info array/dictionairy containing the psd info (like the "psd_layer" and "psd_layerid")
But is this information available using LUA scripts?
I am trying to read the attributes available in the imagelayer, using pairs(), but I cannot print the key/value combination because it is an userdata object.
And is there somewhere I can find some information about PSD_LayerInfotable?
I have unzipped the anime file, and browsed the json content of the .animeproj fileand there I found the info array/dictionairy containing the psd info (like the "psd_layer" and "psd_layerid")
But is this information available using LUA scripts?
I am trying to read the attributes available in the imagelayer, using pairs(), but I cannot print the key/value combination because it is an userdata object.
And is there somewhere I can find some information about PSD_LayerInfotable?
- Lost Marble
- Site Admin
- Posts: 2347
- Joined: Tue Aug 03, 2004 6:02 pm
- Location: Scotts Valley, California, USA
- Contact:
Re: How are individual layers from a .PSD defined in ASP11?
Lua doesn't have access to these unique PSD ID numbers. I'll add access to the next version of Anime Studio, but to be honest I'm not sure how useful it will be. These layer IDs are unique identifiers, and have no relation to the ordering of layers. For example, the bottom layer might have an ID of 27, and the next layer up might have an ID of 136.
Knowing the layer IDs allows Anime Studio to find the same layer again even if you add, remove, or rearrange layers in Photoshop. But it doesn't tell you anything about a layer in relation to its neighbors.
I think I'll also add some functions to let you ask what position a PSD layer is in the PSD layer stack (this is the old *5* notation), and the ability to change that. It sounds like that's what you're after here.
The tricky thing to keep in mind is this:
Anime Studio only loads images on demand. So when you open a document, if a particular image layer is not visible (visibility turned off, not an active switch layers, etc.), the image won't be loaded yet. And if that image is a layer in a PSD file, and Anime doesn't load it yet, it can't know if other layers have been added or removed from the PSD file since the last time it was loaded. The unique layer IDs don't ever change, that's why we switched to them. But if you rely on layer-by-order-IDs, and you add or remove layers in the PSD file, you might get surprises.
So, something to keep in mind. Layer-by-order is kind of fragile if you modify the PSD file's layers. That's why we switched to unique IDs.
Knowing the layer IDs allows Anime Studio to find the same layer again even if you add, remove, or rearrange layers in Photoshop. But it doesn't tell you anything about a layer in relation to its neighbors.
I think I'll also add some functions to let you ask what position a PSD layer is in the PSD layer stack (this is the old *5* notation), and the ability to change that. It sounds like that's what you're after here.
The tricky thing to keep in mind is this:
Anime Studio only loads images on demand. So when you open a document, if a particular image layer is not visible (visibility turned off, not an active switch layers, etc.), the image won't be loaded yet. And if that image is a layer in a PSD file, and Anime doesn't load it yet, it can't know if other layers have been added or removed from the PSD file since the last time it was loaded. The unique layer IDs don't ever change, that's why we switched to them. But if you rely on layer-by-order-IDs, and you add or remove layers in the PSD file, you might get surprises.
So, something to keep in mind. Layer-by-order is kind of fragile if you modify the PSD file's layers. That's why we switched to unique IDs.
- Lost Marble
- Site Admin
- Posts: 2347
- Joined: Tue Aug 03, 2004 6:02 pm
- Location: Scotts Valley, California, USA
- Contact:
Re: How are individual layers from a .PSD defined in ASP11?
I've added the following functions to the ImageLayer class that Lua scripts can use:
void SetSourceImage(const char *path); // set the path of an image - you can use filename.psd*5* notation if you want to
const char *SourceImage(); // return the path of the image being used - *5* notation will have been stripped off
bool IsPSDImage(); // true if the image layer is using a PSD file
void SetUniquePSDLayerID(int32 layerPSDID); // set the unique layer ID that you want to use
int32 UniquePSDLayerID(); // returns the unique ID
void SetPSDLayerOrderID(int32 layerOrderID); // set the layer to use based on its order in the PSD file (0 is the bottom layer, then 1, 2, 3, etc.)
int32 PSDLayerOrderID(); // returns the layer ID by order that is being used
void UnloadImage(); // unloads the image from memory - AS will load it back in if and when it needs to use it
SetSourceImage() and SourceImage() already existed. The others are new.
I think you guys are in the beta - these functions will be available in the next beta release.
void SetSourceImage(const char *path); // set the path of an image - you can use filename.psd*5* notation if you want to
const char *SourceImage(); // return the path of the image being used - *5* notation will have been stripped off
bool IsPSDImage(); // true if the image layer is using a PSD file
void SetUniquePSDLayerID(int32 layerPSDID); // set the unique layer ID that you want to use
int32 UniquePSDLayerID(); // returns the unique ID
void SetPSDLayerOrderID(int32 layerOrderID); // set the layer to use based on its order in the PSD file (0 is the bottom layer, then 1, 2, 3, etc.)
int32 PSDLayerOrderID(); // returns the layer ID by order that is being used
void UnloadImage(); // unloads the image from memory - AS will load it back in if and when it needs to use it
SetSourceImage() and SourceImage() already existed. The others are new.
I think you guys are in the beta - these functions will be available in the next beta release.
-
- Posts: 303
- Joined: Thu May 13, 2010 2:01 pm
Re: How are individual layers from a .PSD defined in ASP11?
Thanks Mike! That helps a lot!
Re: How are individual layers from a .PSD defined in ASP11?
Thanks! We'll be testing it asap.
By the way, the release on november 9th is 17881, but the release on november 3rd was also 17881. Maybe something went wrong?
By the way, the release on november 9th is 17881, but the release on november 3rd was also 17881. Maybe something went wrong?
- Víctor Paredes
- Site Admin
- Posts: 5661
- Joined: Wed Jan 26, 2005 12:18 am
- Location: Barcelona/Chile
- Contact:
Re: How are individual layers from a .PSD defined in ASP11?
Thank you very much, Mike
I just checked, November 3rd was 17811, this one is 17881Lukas wrote:By the way, the release on november 9th is 17881, but the release on november 3rd was also 17881. Maybe something went wrong?
Moho Product Manager
www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
Re: How are individual layers from a .PSD defined in ASP11?
Ahhhhh, so confusing! I actually double checked it... I guess I have numberdyslexiaVíctor Paredes wrote:Thank you very much, Mike
I just checked, November 3rd was 17811, this one is 17881Lukas wrote:By the way, the release on november 9th is 17881, but the release on november 3rd was also 17881. Maybe something went wrong?