*NEW* Switch Icons (updated 12/13/21)

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

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

*NEW* Switch Icons (updated 12/13/21)

Post by synthsin75 »

https://dl.dropboxusercontent.com/s/2wq ... s.zip?dl=0

This tool allows you to animate switches using thumbnail images of the actual switch.

Installation: In your custom content folder, put syn_switch_icons.lua and syn_switch_icons.png in Scripts/Tool. Put the syn_resources folder in Scripts/ScriptResources.

Generate/update button: Generate/update switch thumbnails on frame zero for the selected switch layer/s. You can also alt-click this button to render thumbnails for every switch in the document.
Settings:
  • Icon size: Select small, large, or input your own custom thumbnail size.
  • Arrangement: The thumbnails can be arranged horizontally, vertically, or in blocks. If you only animate one at a time, horizontal will keep it from blocking the workspace. If you need to animate several at once, vertical or square will allow you to see more at a time.
  • Reverse sort: Select whether to reverse the sorting of the switches in the tool options bar or the thumbnails in each switch drop down. This might help if they over run the available space.
  • Spacing: Set how much space is between multiple switch drop downs. This can help keep their thumbnails from overlapping.
  • APPLY button: apply settings changes (or hit <enter> twice to apply) [UPDATE 8/15/21]
  • [UPDATE 8/1/21] Workspace scrub time speed: You can now scrub through the timeline by clicking & dragging in the workspace, so you don't have to move your cursor so far from the switch icons. This setting lets you adjust the relative speed between mouse dragging and timeline scrubbing.
  • Delete all thumbnails: This deletes all the thumbnails stored for the project. If you're done with a project, there's no need to keep them.
  • [UPDATE 12/13/21] Fix for crashing v13.5.2. Some change in 13.5.2 made it so I can no longer update the timeline and layers window when you click a switch icon. So now these update when you click or click & drag in the workspace.
If you switch between two of the same layer type, you'll need to hit ENTER to refresh the tool's UI and show the current layer's switch drop down.

Use:
The drop downs stay open until you hit enter, change layers, or move to/from frame zero. So you can just scrub down the timeline hitting the appropriate switch icon as you go to animate any switch.

There's now a colorized icon option included. Just install that icon and change line 14, as noted in the script.


Enjoy.

Special thanks to A.Evseeva for contributing code and Lukas for Mac testing and code.
Last edited by synthsin75 on Thu Dec 23, 2021 12:04 am, edited 13 times in total.
User avatar
DK
Posts: 2854
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: *NEW* Switch Icons

Post by DK »

Wow....This looks amazing. Well done Wes. Downloading now to try it out.
Many thanks!
D.K
User avatar
DK
Posts: 2854
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: *NEW* Switch Icons

Post by DK »

Wow.....this tool is absolutely amazing! Thanks so much for the time you have spent on this. It should be implemented into the official Moho GUI as it makes animation so much easier when there is a visual reference rather than having to read switch layer names, which after a while, can have you seeing double.
Great tool!

Cheers
D.K
User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Switch Icons

Post by synthsin75 »

Updated the above link, as I corrected a problem that wouldn't let you generate icons for one selected switch layer.
chucky
Posts: 4650
Joined: Sun Jan 28, 2007 4:24 am

Re: *NEW* Switch Icons

Post by chucky »

This tool is truly incredible Wes. Wow doesn't cover it.
Took a few moments to work out what UD was, tricky thing to communicate, so no gripe there.
I'm super impressed, it's very useful and looks great.
User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Switch Icons

Post by synthsin75 »

chucky wrote: Sun May 23, 2021 5:01 am This tool is truly incredible Wes. Wow doesn't cover it.
Tool a few moments to work out what UD was, tricky thing to communicate, so no gripe there.
I was hoping the tool tip was enough to forgo taking up more of the available space, but suggestions welcomed.

Glad you guys are liking it!
User avatar
SimplSam
Posts: 1048
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: *NEW* Switch Icons

Post by SimplSam »

Definitely 10 out of 10. Exceptional tool and very easy to use. I especially like the way that you can work with multiple layers/switches at the same time.

I was gonna say my only gripe was .. "when reopening a project file looks like we need to regenerate the icons". But that only occurred because I was working with an "Untitled" project, later saved as "<newname>". So the link between "<newname>" doc and "Untitled" icons was lost.

Hopefully LM can look at this and provide some helper scripting to make the generation process slightly smoother.

Phenomenal work !!!
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Switch Icons

Post by synthsin75 »

SimplSam wrote: Sun May 23, 2021 5:57 am I was gonna say my only gripe was .. "when reopening a project file looks like we need to regenerate the icons". But that only occurred because I was working with an "Untitled" project, later saved as "<newname>". So the link between "<newname>" doc and "Untitled" icons was lost.
I've updated the above link. It should now handle the open document being saved with a new name after generating icons.
User avatar
DK
Posts: 2854
Joined: Mon Aug 09, 2004 6:06 am
Location: Australia

Re: *NEW* Switch Icons

Post by DK »

Just curious...when it is generating the Switch Thumbs they appear in a sequence and are quite large. What happens to these large images? Are they stored somewhere and require deleting or is this all automated?

Cheers
D.K
User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Switch Icons

Post by synthsin75 »

It only looks large while rendering the icons. They are actually being rendered at the pixel size selected in "Icon size". So it's pretty small images being saved, and they are stored in:
*Custom Content Folder*\Scripts\ScriptResources\syn_resources\*document name folder*
User avatar
Lukas
Posts: 1297
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: *NEW* Switch Icons

Post by Lukas »

Veeery cool Wes!

There's some issues with paths on macOS. You need to add a \ in front of a space-character, and you need to create each directory before creating a subdirectory. For example:

Code: Select all

		local dir
		if opSys == "win" then
			dir = "\""..moho:UserAppDir().."\"".."/scripts/ScriptResources/syn_resources/".."\""..doc.."\"" -- (not 100% sure if I messed this one up, can't test it here)
		else
			dir = moho:UserAppDir().."/scripts/ScriptResources/syn_resources/"
			dir = string.gsub(dir, " ", "\\ ")
			os.execute("mkdir "..dir)
			doc = string.gsub(doc, " ", "\\ ")
			dir = dir..doc
		end
		os.execute("mkdir "..dir)
And os.remove doesn't work either, but os.execute ("rm "..filepath) does, for example:

Code: Select all

				if (string.match(file, "("..subpar.."_"..uid.."_"..size.."_"..".+"..")")) then
					--os.execute("del /q /S ".."\""..moho:UserAppDir().."/scripts/ScriptResources/syn_resources/"..doc.."/"..file.."\"")
					local filepath = moho:UserAppDir().."/scripts/ScriptResources/syn_resources/"..doc.."/"..file
					if opSys == "win" then
						os.remove(filepath)
					else
						filepath = string.gsub(filepath, " ", "\\ ")
						os.execute ("rm "..filepath)
					end
					break
				end
User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Switch Icons

Post by synthsin75 »

Lukas wrote: Sun May 23, 2021 1:05 pm There's some issues with paths on macOS.
Thanks, Lukas! The Mac stuff was completely untested and I knew it was probably not right.
Last edited by synthsin75 on Sun May 23, 2021 7:39 pm, edited 1 time in total.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *NEW* Switch Icons

Post by Greenlaw »

This looks fantastic Wes! Will give it a try.
User avatar
synthsin75
Posts: 9978
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Switch Icons

Post by synthsin75 »

Just updated with fixes for Mac, update button icon, and colorized icon option, all provided by Lukas (thanks again), as well as a minor bug fix.
If you use the colorized icon, you'll need to change line 14, as noted in the script.

Lukas, I think I followed the correct Mac conventions to account for the document being saved to a different name after generating thumbnails, line 509-522. Please let me know if you find that doesn't work.
teotoon
Posts: 135
Joined: Wed Aug 04, 2004 7:19 am
Location: Turkey

Re: *NEW* Switch Icons

Post by teotoon »

This is awesome... Thank you for this wonderful gift to the Moho Community.

Cheers
Post Reply