Recover Maya files after crash

I had Maya crashing on me a couple of times in the last past days and trying to get my files back was just not fun. So I wrote a little script that allows you to recover whatever file(s) Maya managed to save before crashing. Your mileage my vary whether or not the files actually open, but you can always give this a try.

Grab it here – recoverAfterCrash.zip.

  • Put the files in your Maya scripts folder
  • On line 32, set uiFilePath to the path where you saved the ui file. Probably C:\Users\[USERNAME]\Documents\maya\scripts
  • Add the following python script to your shelf:
  • import recoverAfterCrash
    recoverAfterCrash.CreateUI()
    

The code of the script:


##############################################
#
#
# recoverAfterCrash.py
# nielsvaes@gmail.com
#
#
##############################################


#PySide
from PySide.QtCore import * 
from PySide.QtGui import *
from PySide import QtGui as QTGui
from PySide.QtUiTools import *
from shiboken import wrapInstance


#Maya
import maya.cmds as cmds
import maya.mel as mel
from maya import OpenMayaUI as omui

#Python std lib
import os
import tempfile

ui = None

#Change this path to the location of the nameTools.ui
uiFilePath = "<PATH TO THE LOCATION OF>/recoverAfterCrash.ui"

def CreateUI():
	global ui
	global uiFilePath

	mayaMainWindowPtr = omui.MQtUtil.mainWindow()
	mayaMainWindow = wrapInstance(long(mayaMainWindowPtr), QWidget)

	loader = QUiLoader()
	file = QFile(uiFilePath)
	file.open(QFile.ReadOnly)

	ui = loader.load(file, parentWidget = mayaMainWindow)
	file.close()
	
	ui.btnTryToRecover.clicked.connect(TryToRecover)

	Awake()

	ui.setWindowFlags(Qt.Window)
	ui.show()

def Awake():
	tempDir = tempfile.gettempdir()

	foundfiles = []
	for file in os.listdir(tempDir):
		if file.endswith(".ma"):
			item = QListWidgetItem(file)
			ui.lvFiles.addItem(item)

def TryToRecover():
	tempDir = tempfile.gettempdir()
	selectedFile = tempDir + "/" + ui.lvFiles.currentItem().text()

	try:
		cmds.file(selectedFile, open = True)
	except:
		cmds.warning("Couldn't open file or no file selected")

#CreateUI()

The name game

There are a gazillion renaming scripts out there… and now there are a gazillion + 1 renaming tools. If you’ve been using Maya for some time I’m going to assume you already have something to scratch whatever renaming itch you might have, but I decided to group the things I find I need the most. Feel free to use or abuse it as always 🙂

Continue reading

A check up script you might find useful

If you’re working with different people, it’s always important to make sure that everyone follows the same guidelines. There has been many a time where I’ve worked with interns or other people who use wildly different settings than I do in Maya. By the time a model was ready for export, it sometimes wasn’t usable at all in Unity. And it wasn’t because that person did something wrong. It just happened because settings between artists weren’t the same. And that caused a lot of headaches further down the line.

Continue reading

Finding utility nodes through script

My buddy Toby approached me this morning with an interesting question: is there a way to list all utility nodes currently in the scene through code? I assumed he already Googled it himself, but I nevertheless did the same thing. As it turns out, either no one has really asked the question or nobody came up with a very good answer. In a thread from 8 years ago on CGTalk someone suggests making a helper function, check every node in the scene against this helper function and return the type of node. It requires you to hardcode every type of utility node and doesn’t allow for much flexibility. This was probably around the time that Maya 7.0 was the latest version and I really don’t remember much from those days, so maybe this was the most efficient solution back in the day.

Continue reading

Dock any window

One thing that has always bothered me in Maya was that some windows were dockable, but some weren’t. Especially the outliner not being dockable by default has always irritated the crap out of me. That’s why I made this very small, simple script that allows you to take any open window and dock it on the left, right, top or bottom. That way you can merrily work away in 4 views while still having another window docked on the side. Grab it here.

Continue reading