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

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

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

Post 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! :)
Breinmeester
Posts: 303
Joined: Thu May 13, 2010 2:01 pm

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

Post 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!
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

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

Post 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?
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

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

Post by synthsin75 »

I just checked, and these are available in AS11.2, but the scripting documents have not been updated.
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

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

Post by Stan »

synthsin75 wrote:the scripting documents have not been updated.
That's bad... Really bad...
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
User avatar
synthsin75
Posts: 9934
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

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

Post 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.
Stan
Posts: 199
Joined: Sun Apr 19, 2009 3:22 pm

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

Post by Stan »

A question to Mike (or other SmithMicro officials): Is there any other new Lua API features in 11.2?
________________________________________________________________________
https://mohoscripting.com/ - Unofficial Moho Lua scripting documentation
https://mohoscripts.com/ - The best place to publish and download scripts for Moho
Post Reply