Skip to content

Commit

Permalink
Added ability to export CSV with optional playblast link
Browse files Browse the repository at this point in the history
  • Loading branch information
greymind committed Aug 4, 2015
1 parent b3efe2f commit bf504f7
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 14 deletions.
56 changes: 49 additions & 7 deletions Out/Sequencer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import shutil
import fnmatch
import datetime
import glob
import maya.cmds as Cmds
import maya.mel as Mel
import xml.dom.minidom as Dom
Expand Down Expand Up @@ -236,7 +237,7 @@ def FindIndexOf(list, value, start=0, end=-1):

'''
Greymind Sequencer for Maya
Version: 1.7.2
Version: 1.8.0
(c) 2009 - 2015 Greymind Inc.
Balakrishnan (Balki) Ranganathan (balki_live_com)
Expand All @@ -246,7 +247,7 @@ def FindIndexOf(list, value, start=0, end=-1):
# from Common import *
from functools import partial as Partial

SequencerVersion = "1.7.2"
SequencerVersion = "1.8.0"

class Animation:
Id = -1
Expand Down Expand Up @@ -377,6 +378,7 @@ class SequencerUI:
width = 0
height = 0
sequencer = None
IncludePlayblastLinkCheckBox = None

AnimationUIs = {}

Expand Down Expand Up @@ -608,6 +610,13 @@ def SetPlaybackRange(self, startTime, endTime):

def MessageBox(self, dialogMessage, dialogTitle = "Sequencer", dialogButtons=["Ok"]):
Cmds.confirmDialog(title=dialogTitle, message=dialogMessage, button=dialogButtons)

def InputBox(self, dialogMessage, defaultText="", dialogTitle = "Sequencer", dialogButtons=["Ok", "Cancel"]):
result = Cmds.promptDialog(title=dialogTitle, message=dialogMessage, text=defaultText, button=dialogButtons, defaultButton="OK", cancelButton="Cancel", dismissString="Cancel")
if result == "Ok":
return Cmds.promptDialog(query=True, text=True)

return ""

def CountSelected(self):
selectedCount = 0
Expand Down Expand Up @@ -665,7 +674,7 @@ def PlayblastDisplayEnable(self, enable=True):
Cmds.setAttr('persp.displayFieldChart', enable)
Cmds.setAttr('persp.displayResolution', enable)
Cmds.setAttr('persp.displayFilmGate', enable)

def Export(self, extraArg=None):
directoryName = os.path.dirname(Cmds.file(q=True, sn=True))
if not directoryName:
Expand All @@ -676,15 +685,37 @@ def Export(self, extraArg=None):
if selectedCount == 0:
self.MessageBox('Please select animations to export!')
return

includePlayblastLink = Cmds.checkBox(self.IncludePlayblastLinkCheckBox, q=True, value=True)

playblastFolder = ""
if includePlayblastLink:
playblastFolder = self.InputBox("Enter directory that contains the playblasts", directoryName)
if not playblastFolder:
self.MessageBox("Please enter a playblast folder. Export canceled.")
return

playblastPrefix = self.InputBox("Enter prefix (if any)")

now = datetime.datetime.now()
exportFilename = "%s/Export %d%d%d-%d%d%d.csv" % (directoryName, now.year, now.month, now.day, now.hour, now.minute, now.second)
exportFile = open(exportFilename, "w")

exportFile.write("%s, %s, %s\n" % ('Animation Name', 'Start Frame', 'End Frame'))
if not includePlayblastLink:
exportFile.write("%s,%s,%s\n" % ('Animation Name', 'Start Frame', 'End Frame'))
else:
exportFile.write("%s,%s,%s,%s\n" % ('Animation Name', 'Start Frame', 'End Frame', 'Playblast'))

for animation in self.sequencer.Animations.values():
if animation.Selected == True:
exportFile.write("%s, %d, %d\n" % (animation.Name, animation.StartFrame, animation.EndFrame))
if not includePlayblastLink:
exportFile.write("%s,%d,%d\n" % (animation.Name, animation.StartFrame, animation.EndFrame))
else:
playblastLink = "%s.avi" % self.GetPlayblastMovieFilename(playblastFolder, playblastPrefix, animation)
if os.path.isfile(playblastLink):
exportFile.write("%s,%d,%d,\"=HYPERLINK(\"\"%s\"\", \"\"[open]\"\")\"\n" % (animation.Name, animation.StartFrame, animation.EndFrame, playblastLink))
else:
exportFile.write("%s,%d,%d,n/a\n" % (animation.Name, animation.StartFrame, animation.EndFrame))

exportFile.close()

Expand Down Expand Up @@ -729,12 +760,18 @@ def GeneratePlayblast(self, extraArg=None):
if animation.Selected == True:
self.SetPlaybackRange(animation.StartFrame, animation.EndFrame)

movieFilename = "%s/%s%s" % (directoryName, prefixText, animation.Name.replace("\"", "_").replace("*", "_"))
movieFilename = self.GetPlayblastMovieFilename(directoryName, prefixText, animation)
Cmds.playblast(format='movie', filename=movieFilename, clearCache=True, viewer=False, showOrnaments=True, fp=4, percent=scalePercentage, compression='none', widthHeight=(horizontalResolution, verticalResolution), fo=True)
self.StepProgressBar(1)

self.EndProgressBar()
self.MessageBox('Playblast generation complete!')

def GetPlayblastMovieFilename(self, directoryName, prefixText, animation):
assert(directoryName)
assert(animation)

return "%s/%s%s" % (directoryName, prefixText, animation.Name.replace("\"", "_").replace("*", "_"))

def BakeKeys(self, extraArg=None):
selection = Cmds.ls(selection=True)
Expand Down Expand Up @@ -917,7 +954,6 @@ def Create(self):
Cmds.button(label='Move Up', c=Partial(self.MoveUp))
Cmds.button(label='Move Down', c=Partial(self.MoveDown))
Cmds.button(label='Refresh', backgroundColor=[0.6, 0.6, 0.9], c=Partial(self.Refresh))
Cmds.button(label='Export', backgroundColor=[0.6, 0.6, 0.9], c=Partial(self.Export))

self.CreateSeparator()

Expand All @@ -938,6 +974,12 @@ def Create(self):
Cmds.text(label=' To generate multiple playblasts')
Cmds.button(label='PlayBlast', c=Partial(self.GeneratePlayblast), backgroundColor=[0.9, 0.9, 0.8])

Cmds.setParent('..')
Cmds.rowLayout(numberOfColumns = 3, columnWidth3=[200, 90, 48], columnAlign3=['left', 'left', 'left'])
Cmds.text(label=' To export animation list as CSV')
Cmds.button(label='Export to CSV', c=Partial(self.Export), backgroundColor=[0.9, 0.9, 0.8])
self.IncludePlayblastLinkCheckBox = Cmds.checkBox(label='playblast link')

Cmds.setParent('..')
Cmds.rowLayout(numberOfColumns = 2, columnWidth2=[200, 48], columnAlign2=['left', 'left'])
Cmds.text(label=' To generate animation-aware FBX')
Expand Down
1 change: 1 addition & 0 deletions Scripts/Common.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import shutil
import fnmatch
import datetime
import glob
import maya.cmds as Cmds
import maya.mel as Mel
import xml.dom.minidom as Dom
Expand Down
55 changes: 48 additions & 7 deletions Scripts/Sequencer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'''
Greymind Sequencer for Maya
Version: 1.7.2
Version: 1.8.0
(c) 2009 - 2015 Greymind Inc.
Balakrishnan (Balki) Ranganathan (balki_live_com)
Expand All @@ -10,7 +10,7 @@
# from Common import *
from functools import partial as Partial

SequencerVersion = "1.7.2"
SequencerVersion = "1.8.0"

class Animation:
Id = -1
Expand Down Expand Up @@ -141,6 +141,7 @@ class SequencerUI:
width = 0
height = 0
sequencer = None
IncludePlayblastLinkCheckBox = None

AnimationUIs = {}

Expand Down Expand Up @@ -372,6 +373,13 @@ def SetPlaybackRange(self, startTime, endTime):

def MessageBox(self, dialogMessage, dialogTitle = "Sequencer", dialogButtons=["Ok"]):
Cmds.confirmDialog(title=dialogTitle, message=dialogMessage, button=dialogButtons)

def InputBox(self, dialogMessage, defaultText="", dialogTitle = "Sequencer", dialogButtons=["Ok", "Cancel"]):
result = Cmds.promptDialog(title=dialogTitle, message=dialogMessage, text=defaultText, button=dialogButtons, defaultButton="OK", cancelButton="Cancel", dismissString="Cancel")
if result == "Ok":
return Cmds.promptDialog(query=True, text=True)

return ""

def CountSelected(self):
selectedCount = 0
Expand Down Expand Up @@ -429,7 +437,7 @@ def PlayblastDisplayEnable(self, enable=True):
Cmds.setAttr('persp.displayFieldChart', enable)
Cmds.setAttr('persp.displayResolution', enable)
Cmds.setAttr('persp.displayFilmGate', enable)

def Export(self, extraArg=None):
directoryName = os.path.dirname(Cmds.file(q=True, sn=True))
if not directoryName:
Expand All @@ -440,15 +448,37 @@ def Export(self, extraArg=None):
if selectedCount == 0:
self.MessageBox('Please select animations to export!')
return

includePlayblastLink = Cmds.checkBox(self.IncludePlayblastLinkCheckBox, q=True, value=True)

playblastFolder = ""
if includePlayblastLink:
playblastFolder = self.InputBox("Enter directory that contains the playblasts", directoryName)
if not playblastFolder:
self.MessageBox("Please enter a playblast folder. Export canceled.")
return

playblastPrefix = self.InputBox("Enter prefix (if any)")

now = datetime.datetime.now()
exportFilename = "%s/Export %d%d%d-%d%d%d.csv" % (directoryName, now.year, now.month, now.day, now.hour, now.minute, now.second)
exportFile = open(exportFilename, "w")

exportFile.write("%s, %s, %s\n" % ('Animation Name', 'Start Frame', 'End Frame'))
if not includePlayblastLink:
exportFile.write("%s,%s,%s\n" % ('Animation Name', 'Start Frame', 'End Frame'))
else:
exportFile.write("%s,%s,%s,%s\n" % ('Animation Name', 'Start Frame', 'End Frame', 'Playblast'))

for animation in self.sequencer.Animations.values():
if animation.Selected == True:
exportFile.write("%s, %d, %d\n" % (animation.Name, animation.StartFrame, animation.EndFrame))
if not includePlayblastLink:
exportFile.write("%s,%d,%d\n" % (animation.Name, animation.StartFrame, animation.EndFrame))
else:
playblastLink = "%s.avi" % self.GetPlayblastMovieFilename(playblastFolder, playblastPrefix, animation)
if os.path.isfile(playblastLink):
exportFile.write("%s,%d,%d,\"=HYPERLINK(\"\"%s\"\", \"\"[open]\"\")\"\n" % (animation.Name, animation.StartFrame, animation.EndFrame, playblastLink))
else:
exportFile.write("%s,%d,%d,n/a\n" % (animation.Name, animation.StartFrame, animation.EndFrame))

exportFile.close()

Expand Down Expand Up @@ -493,12 +523,18 @@ def GeneratePlayblast(self, extraArg=None):
if animation.Selected == True:
self.SetPlaybackRange(animation.StartFrame, animation.EndFrame)

movieFilename = "%s/%s%s" % (directoryName, prefixText, animation.Name.replace("\"", "_").replace("*", "_"))
movieFilename = self.GetPlayblastMovieFilename(directoryName, prefixText, animation)
Cmds.playblast(format='movie', filename=movieFilename, clearCache=True, viewer=False, showOrnaments=True, fp=4, percent=scalePercentage, compression='none', widthHeight=(horizontalResolution, verticalResolution), fo=True)
self.StepProgressBar(1)

self.EndProgressBar()
self.MessageBox('Playblast generation complete!')

def GetPlayblastMovieFilename(self, directoryName, prefixText, animation):
assert(directoryName)
assert(animation)

return "%s/%s%s" % (directoryName, prefixText, animation.Name.replace("\"", "_").replace("*", "_"))

def BakeKeys(self, extraArg=None):
selection = Cmds.ls(selection=True)
Expand Down Expand Up @@ -681,7 +717,6 @@ def Create(self):
Cmds.button(label='Move Up', c=Partial(self.MoveUp))
Cmds.button(label='Move Down', c=Partial(self.MoveDown))
Cmds.button(label='Refresh', backgroundColor=[0.6, 0.6, 0.9], c=Partial(self.Refresh))
Cmds.button(label='Export', backgroundColor=[0.6, 0.6, 0.9], c=Partial(self.Export))

self.CreateSeparator()

Expand All @@ -702,6 +737,12 @@ def Create(self):
Cmds.text(label=' To generate multiple playblasts')
Cmds.button(label='PlayBlast', c=Partial(self.GeneratePlayblast), backgroundColor=[0.9, 0.9, 0.8])

Cmds.setParent('..')
Cmds.rowLayout(numberOfColumns = 3, columnWidth3=[200, 90, 48], columnAlign3=['left', 'left', 'left'])
Cmds.text(label=' To export animation list as CSV')
Cmds.button(label='Export to CSV', c=Partial(self.Export), backgroundColor=[0.9, 0.9, 0.8])
self.IncludePlayblastLinkCheckBox = Cmds.checkBox(label='playblast link')

Cmds.setParent('..')
Cmds.rowLayout(numberOfColumns = 2, columnWidth2=[200, 48], columnAlign2=['left', 'left'])
Cmds.text(label=' To generate animation-aware FBX')
Expand Down

0 comments on commit bf504f7

Please sign in to comment.