Script to enable animated noise for multiple vector layers?

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
Lukas
Posts: 1296
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Script to enable animated noise for multiple vector layers?

Post by Lukas »

Maybe a scripter can help me out here?

I have a lot of projects where I have to enable Noisy outlines, Noisy fills & Animated noise on all vector layers. A script that would change this for all (or all selected) vector layers, would be great.

If it's not too hard to script, I'd appreciate it a lot!
User avatar
Onionskin
Posts: 253
Joined: Wed Mar 04, 2009 2:01 pm

Re: Script to enable animated noise for multiple vector laye

Post by Onionskin »

You can do this with Ramon's lost layer tool viewtopic.php?f=12&t=16862 , but first you have to select all vector layers, if it is to much work try with this menu script, but for noise settings you must go into the script code and change manually.

Code: Select all

-- **************************************************
-- Provide Moho with the name of this script object
-- **************************************************

ScriptName = "LM_Sketchy"

-- **************************************************
-- General information about this script
-- **************************************************

LM_Sketchy = {}

LM_Sketchy.BASE_STR = 2480

function LM_Sketchy:Name()
	return "Sketchy"
end

function LM_Sketchy:Version()
	return "6.0"
end

function LM_Sketchy:Description()
	return MOHO.Localize("/Scripts/Menu/Sketchy/Description=Applies a sketchy line style to all vector layers in the document.")
end

function LM_Sketchy:Creator()
	return "Smith Micro Software, Inc."
end

function LM_Sketchy:UILabel()
	return(MOHO.Localize("/Scripts/Menu/Sketchy/ApplySketchyEffect=Apply Sketchy Effect"))
end

-- **************************************************
-- The guts of this script
-- **************************************************

function LM_Sketchy:IsEnabled(moho)
	return true
end

function LM_Sketchy:ConvertLayer(moho, layer)
	if (layer:LayerType() == MOHO.LT_VECTOR) then
		local vectorLayer = moho:LayerAsVector(layer)
		vectorLayer.fNoisyLines = true
		vectorLayer.fAnimatedNoise = true;
		vectorLayer.fExtraSketchy = true;
		vectorLayer.fExtraLines = 5;
		vectorLayer.fNoiseAmp = 6.0 / moho.document:Height();
		vectorLayer.fNoiseScale = 48.0 / moho.document:Height();
	elseif layer:IsGroupType() then
		local groupLayer = moho:LayerAsGroup(layer)
		for i = 1, groupLayer:CountLayers() do
			local subLayer = groupLayer:Layer(i - 1)
			self:ConvertLayer(moho, subLayer)
		end
	end
end

function LM_Sketchy:Run(moho)
	for i = 1, moho.document:CountLayers() do
		moho.document:Layer(i - 1):SetSecondarySelection(true)
	end

	moho.document:PrepMultiUndo()
	moho.document:SetDirty()

	for i = 1, moho.document:CountLayers() do
		moho.document:Layer(i - 1):SetSecondarySelection(false)
	end

	for i = 1, moho.document:CountLayers() do
		local layer = moho.document:Layer(i - 1)
		self:ConvertLayer(moho, layer)
	end
end
User avatar
Onionskin
Posts: 253
Joined: Wed Mar 04, 2009 2:01 pm

Re: Script to enable animated noise for multiple vector laye

Post by Onionskin »

omg, one correction, seems like script above is not custom, it is official in ASP under scripts/draw/apply sketchy effect
User avatar
Lukas
Posts: 1296
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Script to enable animated noise for multiple vector laye

Post by Lukas »

Thanks for the quick reply! I didn't know (or forgot about it because it's tucked away)!

This is gonna save me a lot of time :)
User avatar
Onionskin
Posts: 253
Joined: Wed Mar 04, 2009 2:01 pm

Re: Script to enable animated noise for multiple vector laye

Post by Onionskin »

now I remember, I had script like you described but it won't work in 9.5. It was made by Stan and with some Wes modification it was great http://www.kelleytown.com/forum/animato ... PIC_ID=312
User avatar
Lukas
Posts: 1296
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: Script to enable animated noise for multiple vector laye

Post by Lukas »

Thanks :)

I added vectorLayer.fNoisyShapes = true; and changed the settings in the original script, it took me some time to figure out it wasn't fNoisyFills. Works great now. Cheers!
Post Reply