write layer script workflow

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

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

write layer script workflow

Post by davoodice2 »

hi.
I want to test my layer script. but each time i have to create new layer and assign script. ctrl+shift+alt+L doesn't work. can any body give a better workflow?
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
hayasidist
Posts: 3526
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: write layer script workflow

Post by hayasidist »

I thought I had a script for this - but I can't find it right now -- but if you use MohoLayer:SetLayerScript(path) you can remove and reload the file ..

[edit]oh forget it:
Stan has one: https://mohoscripts.com/script/sz_refresh_layerscript
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: write layer script workflow

Post by davoodice2 »

thanks friends.
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
synthsin75
Posts: 9979
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: write layer script workflow

Post by synthsin75 »

davoodice2 wrote: Sun Nov 07, 2021 11:22 am hi.
I want to test my layer script. but each time i have to create new layer and assign script. ctrl+shift+alt+L doesn't work. can any body give a better workflow?
You can actually unembed, hit apply, and reembed, but the scripts make it much faster. My own just reloads all the layerscripts, probably like Stan's.

Code: Select all

function Syn_ReloadLayerScripts:Run(moho)
	local count = 0
	repeat
		local layer = moho.document:LayerByAbsoluteID(count)
		if layer then
			count = count + 1
			local script = layer:LayerScript()
			layer:SetLayerScript("")
			layer:SetLayerScript(script)
		end
	until not layer 
end
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: write layer script workflow

Post by davoodice2 »

synthsin75 wrote: Sun Nov 07, 2021 11:54 pm
davoodice2 wrote: Sun Nov 07, 2021 11:22 am hi.
I want to test my layer script. but each time i have to create new layer and assign script. ctrl+shift+alt+L doesn't work. can any body give a better workflow?
You can actually unembed, hit apply, and reembed, but the scripts make it much faster. My own just reloads all the layerscripts, probably like Stan's.

Code: Select all

function Syn_ReloadLayerScripts:Run(moho)
	local count = 0
	repeat
		local layer = moho.document:LayerByAbsoluteID(count)
		if layer then
			count = count + 1
			local script = layer:LayerScript()
			layer:SetLayerScript("")
			layer:SetLayerScript(script)
		end
	until not layer 
end
thanks
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
Post Reply