*NEW* Find and delete negative keyframes

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: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Find and delete negative keyframes

Post by synthsin75 »

In another thread, someone also mentioned trying this:
Daxel wrote: Tue Mar 16, 2021 12:53 am Another tip: If the script doesn't find negative keyframes or you keep having performance problems, try deleting the reference layers and creating them again because they can get corrupted in certain situations. When that happens the .moho file size increases a lot and causes performance problems but what I told you solves the problem easily.
Daxel
Posts: 996
Joined: Wed Mar 27, 2019 8:34 pm

Re: *NEW* Find and delete negative keyframes

Post by Daxel »

kgeetvcartoons wrote: Thu Mar 18, 2021 3:16 am THANK YOU SO MUCH! It worked. It didn't find any negative keyframes so we'll work from there!
Thanks again!
Do you have reference layers? Try to delete them and see if performance improves. If it does, you can create the references again. Sometimes they get corrupted and slow Moho down.
Edit: oh I didn't see Wes mentioned this already. Anyway, did you solve your performance problem?
User avatar
Lukas
Posts: 1296
Joined: Fri Apr 09, 2010 9:00 am
Location: Netherlands
Contact:

Re: *NEW* Find and delete negative keyframes

Post by Lukas »

I've been running your script automatically on opening files, because there were some instances were corrupt layers were copied to many shots and it became impossible to work on the project. It has saved me a lot of headaches. (I did remove the "There were no keyframes found in the negative timeline." alert.)

Here's a script to run scripts automatically on opening files. Save it as LK_AutoRun.lua in your tools folder. Just add SomeScript:Run(moho) or any code within the LK_AutoRun:Scripts(moho) function and it will automatically run on opening saved files (there's a small exception when re-opening the same file, but ctrl+n cltr+w will make it run again). I've been using it to run various project management scripts. But it's been the most useful for Wes' negative keyframes script.

Code: Select all

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

ScriptName = "LK_AutoRun"

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

LK_AutoRun = {}

function LK_AutoRun:Name()
	return "Auto Run Script"
end

function LK_AutoRun:Version()
	return "0"
end

function LK_AutoRun:Description()
	return "Auto Run Scripts"
end

function LK_AutoRun:Creator()
	return "Lukas Krepel, Frame Order"
end

function LK_AutoRun:UILabel()
	return("Auto Run Script")
end

function LK_AutoRun:IsRelevant(moho)
	if (MohoMode == nil or MohoMode:Vanilla()) then
		return false
	else
		self:Run(moho)
		return false
	end
end

function LK_AutoRun:IsEnabled(moho)
	self:Run(moho)
	return false
end

LK_AutoRun.LastDocument = ""

-- **************************************************
-- Check if we have already run on this document.
-- Does not work when opening the same file after just closing it.
-- If you DO want to run it in that case, just create and close a new empty file.
-- **************************************************
function LK_AutoRun:Run(moho)
	local thisDocument = moho.document:Path()
	if (self.LastDocument ~= thisDocument) then
		self.LastDocument = thisDocument
		self:Scripts(moho)
	end
end

-- **************************************************
-- Put all code you want to run automatically in this function:
-- **************************************************
function LK_AutoRun:Scripts(moho)
	Syn_NegativeKeys:Run(moho)
end
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Find and delete negative keyframes

Post by synthsin75 »

Nice one, Lukas. I've been using the IsRelevant or IsEnabled functions to automatically run code for years.

Currently, I'm using it to invoke a button script's settings dialog, that I only need once, at most, every time I start Moho.
kgeetvcartoons
Posts: 37
Joined: Fri Mar 12, 2021 2:34 am

Re: *NEW* Find and delete negative keyframes

Post by kgeetvcartoons »

I have moho 13.5 and your script is not available. Can you please give me the info of how to download and where to get the download again? I see the copy and paste but I don't have a clue what to do with it.
User avatar
Greenlaw
Posts: 9259
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *NEW* Find and delete negative keyframes

Post by Greenlaw »

The link is in the first post, and the current version works for Moho 13.5. When the script is updated, this same link will download the latest version.

If you want Lukas 'auto-run' mod, just copy and paste the text from his post above exactly as instructed.

Hope this helps.
AHMED003ADALAT
Posts: 50
Joined: Wed Dec 20, 2017 11:27 pm

Re: *NEW* Find and delete negative keyframes

Post by AHMED003ADALAT »

link lead to 404 error
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Find and delete negative keyframes

Post by synthsin75 »

AHMED003ADALAT wrote: Sat Sep 04, 2021 3:56 am link lead to 404 error
Link fixed: https://drive.google.com/uc?export=down ... f-pbWRqj1a
Last edited by synthsin75 on Thu Nov 04, 2021 6:28 pm, edited 1 time in total.
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: *NEW* Find and delete negative keyframes

Post by davoodice2 »

Greenlaw wrote: Sun Sep 29, 2019 3:43 pm
catwrestler wrote: Sat Sep 28, 2019 3:39 am Negative keys... interesting. I'm wondering what are major causes and how do I know I have them?
Coincidentally, a user in another forum asked this same question yesterday, so I'm re-posting an edited version of my reply here:

You'll know when this happens: Moho will suddenly crawl like it's processing the entire internet. :)

This happens when Moho places an unintended keyframe thousands of frames before frame zero, which apparently causes the computer to evaluate every frame in-between. It takes only one of these unintended keyframes to seriously impact Moho's performance. If there's more than one, Moho may become unusable. By 'serious impact', I mean basic actions like trying to animate a bone or copy and paste a keyframe will make Moho take a long pause, and getting any work done will take forever.

To fix this previously, you had to copy the visible keyframes for each channel, delete the entire channel, and then paste the intended keyframes back into the channel. Then you had to repeat this for every channel until you were sure you got rid of any and all of the unintended keyframes. Needless to say, this could be a huge time-waster. Or, if you know what to look for, you could search for the bad keyframes in the project file using a text editor and delete the keys that way.

Wes' script simplifies the process to a single command.

FYI, this issue happened to me Friday at work: A Moho rigged character I was animating suddenly became sluggish for no apparent reason. Even copying and pasting keys took forever. Prior to this slow-down, the rig was very responsive and quick to animate, so I was pretty sure I had at least one negative keyframe in this project.

When I ran Wes' script, it confirmed that this was indeed the case and it fixed the problem instantly.

If the script says there are no negative keyframes in the project, then at least you know to look elsewhere for the problem.

As mentioned above, you should save a backup copy of your project before running this script, just in case it does more harm than help.

Nobody seems to know why it happens but fortunately the problem occurs rarely. Also, it may occur in Moho 12.5 and earlier but I'm not yet sure that this happens in Moho 13.
2 days ago my moho became like turtle 🐢. I restart several time moho and pc until problem be solved. I even wanted to go and cut off the main electricity in the city
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
animated_magic
Posts: 7
Joined: Thu Sep 29, 2016 1:39 pm

Re: *NEW* Find and delete negative keyframes

Post by animated_magic »

Thank you Wes, you're a life saver! Had negative keyframes happen a couple of times and it was driving me a slightly crazy. This script is brilliant!
User avatar
synthsin75
Posts: 9968
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *NEW* Find and delete negative keyframes

Post by synthsin75 »

Always happy to hear old scripts are still helping people.
Post Reply