Created
August 6, 2019 13:13
-
-
Save Onefabis/5edf4f7db3f69fbb9b5af139887c5ff5 to your computer and use it in GitHub Desktop.
Autofill game exporter from timelineMarkers data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.mel as mel | |
import maya.cmds as mc | |
import os | |
import json | |
path = mc.file(q=1, sn=1).rsplit( '/', 1 )[0] | |
stored = mc.fileInfo( "timelineMarkers", q=1 ) | |
if stored: info = json.loads( stored[ 0 ].replace( '\\"', '"') ) | |
else: info = dict() | |
frames = info.get( "frames" ) or [] | |
comments = info.get( "comments" ) or [] | |
if frames and comments: | |
if not mc.window( 'gameExporterWindow', ex=1 ): | |
mel.eval('gameFbxExporter;') | |
frameSet = sorted( frames ) | |
for f in xrange( len(frameSet) ): | |
commentIndex = frames.index(frameSet[f]) | |
if f != len(frameSet)-1: | |
if comments[commentIndex]: | |
animName = comments[commentIndex] | |
else: | |
animName = 'Anim_' + str(frameSet[f]) + '_' + str(frameSet[f+1]) | |
mc.setAttr( 'gameExporterPreset2.animClips[%i].animClipName' %f, animName, type='string' ) | |
mc.setAttr( 'gameExporterPreset2.animClips[%i].animClipStart' %f, frameSet[f] ) | |
mc.setAttr( 'gameExporterPreset2.animClips[%i].animClipEnd' %f, frameSet[f+1] ) | |
mc.setAttr( 'gameExporterPreset2.exportPath', path + '/FBX', type='string' ) | |
if mc.window( 'gameExporterWindow', ex=1 ): | |
mc.deleteUI( 'gameExporterWindow' ) | |
mel.eval('gameFbxExporter;') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment