Page 2 of 2

Re: How are individual layers from a .PSD defined in ASP11?

Posted: Mon Nov 23, 2015 1:40 pm
by Breinmeester
Hi Mike. I tried this piece of code on a rig consisting of a single PSD file, but it returns '-2' as the UniquePSDLayerID for every layer:

Code: Select all

function DV_ChangeImageSource:process_layerDown(moho, layer)

	if (layer:LayerType() == MOHO.LT_IMAGE) then
		local imageLayer = moho:LayerAsImage(layer)
		print(imageLayer:Name())
		print(imageLayer:UniquePSDLayerID())
	elseif layer:IsGroupType() then
		local groupLayer = moho:LayerAsGroup(layer)
		for i = 0, groupLayer:CountLayers()-1 do
			local subLayer = groupLayer:Layer(i)
			self:process_layerDown(moho, subLayer)
		end
	end
end
Am i missing something here? Any help is much appreciated! :)

Re: How are individual layers from a .PSD defined in ASP11?

Posted: Tue Nov 24, 2015 10:49 am
by Breinmeester
I got the script working, but by using the LayerOrderID. Ideally i would like to use the UniquePSDLayerID so i can add and move layers around in the PSD file. But i can't figure out how and when to set the UniquePSDLayerID for it to work. Could you give us an example, Mike? Also, what does -2 as a UniquePSDLayerID mean? Thanks!

Re: How are individual layers from a .PSD defined in ASP11?

Posted: Wed Mar 09, 2016 3:26 am
by Stan
Lost Marble wrote: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.
I'm not in the beta. Those methods are not included in the 11.2 pkg files. Are they only available in the beta? Are the pkg files keep being updated?

Re: How are individual layers from a .PSD defined in ASP11?

Posted: Wed Mar 09, 2016 3:54 am
by synthsin75
I just checked, and these are available in AS11.2, but the scripting documents have not been updated.

Re: How are individual layers from a .PSD defined in ASP11?

Posted: Wed Mar 09, 2016 4:05 am
by Stan
synthsin75 wrote:the scripting documents have not been updated.
That's bad... Really bad...

Re: How are individual layers from a .PSD defined in ASP11?

Posted: Wed Mar 09, 2016 4:06 am
by synthsin75
Stan wrote:
synthsin75 wrote:the scripting documents have not been updated.
That's bad... Really bad...
I agree. I thought this was a standard part of new releases.

Re: How are individual layers from a .PSD defined in ASP11?

Posted: Wed Mar 09, 2016 4:31 am
by Stan
A question to Mike (or other SmithMicro officials): Is there any other new Lua API features in 11.2?