Created
November 22, 2016 09:18
-
-
Save whaison/0e4bfaa4e20e9ae40ce6ee135f8eac6d to your computer and use it in GitHub Desktop.
Mayabatch_motionbuilderFBX_To_oneTimeLine_Enemy.py
This file contains 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
# -*- coding: utf-8 -*- | |
import sys; | |
from maya import cmds | |
import pymel.core as pm | |
import shutil | |
import os | |
# -*- coding: utf-8 -*- | |
import os.path | |
import sys; | |
import maya.cmds as cmds | |
import maya as maya | |
import maya.mel as mel | |
import pymel.core as pm | |
import os | |
import os.path | |
import math | |
#from python.MotionMerge.p015Reference_importReference import Reference_importReference_Simple_workspaces_all_do_method_Class | |
#from python.MotionMerge.p020workspaces_all_do_method_010_move_value_zero_start import Workspaces_all_do_method_010_move_value_zero_start_class | |
from python.MotionMerge.p030motionbuilder_chimera_0_Start import Motionbuilder_chimera_0_Start_Fbx_to_mayaBinary_Class #OK | |
from python import Debug | |
from datetime import datetime | |
#import maya.standalone | |
#maya.standalone.initialize( name='python' ) | |
print("==============Mayabatch_refImport_And_oneTimeLine_Chara.py.py inside================sys.argv=") | |
print sys.argv | |
print("==============Mayabatch_refImport_And_oneTimeLine_Chara.py.py inside================sys.argv=") | |
Debug=Debug.Debug | |
def FileAppendStr(filepath,str): | |
print(u"===========FileAppendStr(filepath= "+filepath+",str= "+str+")=============") | |
f = open(filepath, 'a') | |
f.write(str) | |
f.close() | |
def SaveTextFile(filepath,outputText): | |
print("==============================SaveTextFile================================Start") | |
saveTxtPath=filepath | |
fileExCheckHead0=os.path.exists(saveTxtPath) and os.path.getsize(saveTxtPath) | |
outputTxt=outputText | |
#////////////////////////////////////////////////////write | |
fileExCheckHead=os.path.exists(saveTxtPath) and os.path.getsize(saveTxtPath) | |
if fileExCheckHead == 0: | |
print ("file is not exist make new Text File $saveTxtPath= " + saveTxtPath) | |
#-------------------------------------------------- inside text File Delete | |
#Put the file path to a variable | |
exampleFileName=saveTxtPath | |
#Put the file identifier to a variable | |
fileId=open(exampleFileName,"w") | |
#string you want to write | |
fileId.write("") | |
#write end | |
fileId.close() | |
#pm.internal.shellOutput("echo " + str(outputTxt) + " >> " + saveTxtPath, convertNewlines=False, stripTrailingNewline=False) | |
FileAppendStr(saveTxtPath,outputTxt+"\n") | |
#---------------------------------------------------------- | |
else: | |
print ("txt is Found reSave Text File $saveTxtPath= " + saveTxtPath) | |
#type return.txt >> output.txt | |
#pm.internal.shellOutput("echo " + str(outputTxt) + " >> " + saveTxtPath, convertNewlines=False, stripTrailingNewline=False) | |
FileAppendStr(saveTxtPath,outputTxt+"\n") | |
print ("==============================SaveTextFile================================End") | |
#///////////////////////////////////////////////////////////////// | |
def LogAndTimeSave(title="none"): | |
workspaceRootDirectory=cmds.workspace( q=True, directory=True ,rootDirectory=True) | |
FilePath=workspaceRootDirectory+"Auto_Log.txt" | |
datetimeObj=datetime.now() | |
datetimeStr=datetimeObj.strftime('%Y/%m/%d %H:%M:%S') | |
str=datetimeStr+" , "+title+"\n" | |
print("FilePath="+FilePath) | |
print("str="+str) | |
SaveTextFile(FilePath,str) | |
def p03_Fbx_to_mayaBinaryWorkSpace(): | |
LogAndTimeSave("p03_Fbx_to_mayaBinaryWorkSpace ") | |
print("p03_Fbx_to_mayaBinaryWorkSpace starting............................................p03_Fbx_to_mayaBinaryWorkSpace") | |
Fbx_to_mayaBinary_ClassInstance = Motionbuilder_chimera_0_Start_Fbx_to_mayaBinary_Class.Motionbuilder_chimera_0_Start_Fbx_to_mayaBinary_Class() | |
Fbx_to_mayaBinary_ClassInstance.motionbuilder_chimera_0_Start_Fbx_to_mayaBinary() | |
print("p03_Fbx_to_mayaBinaryWorkSpace Ending...........................................p03_Fbx_to_mayaBinaryWorkSpace") | |
LogAndTimeSave(" END ") | |
def evalMelsetProject_E00100(FullDirPath): | |
print("-----------------------------------maya.mel.eval evalMelsetProject(evalstr)----------------------------------------")# 20161121 | |
evalstr='setProject("'+FullDirPath+'");' #OK | |
print("evalstr="+evalstr); | |
maya.mel.eval(evalstr) #OK | |
print("----------------------------------maya.mel.eval evalMelsetProject(evalstr) End----------------------------------") | |
def p02_SetWorkSpace(workspacepath): | |
LogAndTimeSave("p02_SetWorkSpace ") | |
print ("p02_SetWorkSpace (workspacepath="+workspacepath) | |
#path = 'C:/temp' | |
#path = workspacepath | |
#mel.eval('string $path = "%s";' % path) | |
#evalstr='string $path = "'+path+'" ;' | |
#print ("evalstr= "+evalstr) | |
#mel.eval(evalstr) | |
#mel.eval('print("$path= "+$path)') | |
#print("") | |
#mel.eval('setProject $path;') | |
cmds.workspace( directory=workspacepath) | |
evalMelsetProject_E00100(workspacepath) | |
#baseWorkspacePathStr=cmds.workspace( q=True,baseWorkspace=True) | |
#print("p02_SetWorkSpace baseWorkspacePathStr="+baseWorkspacePathStr) | |
cmds.workspace( saveWorkspace=True) | |
workspaceRootDirectory=cmds.workspace( q=True, directory=True ,rootDirectory=True) | |
print("p02_SetWorkSpace workspace RootDirectory setting="+workspaceRootDirectory) | |
p03_Fbx_to_mayaBinaryWorkSpace() | |
def rigBakeAndOnelineOutput(): | |
Instance = Workspaces_all_do_method_010_move_value_zero_start_class.Workspaces_all_do_method_010_move_value_zero_start_class() | |
#Call Method | |
Instance.workspaces_all_do_method_010_move_value_zero_start_py() | |
def p01_UnEscapeWorksSpacePath(pathstr): | |
LogAndTimeSave("p01_UnEscapeWorksSpacePath") | |
print ("p01_UnEscapeWorksSpacePath (pathstr="+pathstr) | |
if pathstr.find('////')!=-1: | |
global IHaveCmdWorkSpacePath | |
IHaveCmdWorkSpacePath=1 | |
global CmdWorkSpacePath | |
CmdWorkSpacePath=pathstr | |
print("p01_UnEscapeWorksSpacePath found OK CmdWorkSpacePath= "+CmdWorkSpacePath) | |
# すべて置換 | |
CmdWorkSpacePath = CmdWorkSpacePath.replace("////", ":/") | |
print("rp01_UnEscapeWorksSpacePath eprace //// CmdWorkSpacePath= "+CmdWorkSpacePath) | |
p02_SetWorkSpace(CmdWorkSpacePath+"/") | |
else: | |
print("////is Notfound") | |
def Mayabatch_motionbuilderFBX_To_oneTimeLine_Enemy(workspacepath): | |
print ("Mayabatch_refImport_And_oneTimeLine_Chara (workspacepath="+workspacepath) | |
p01_UnEscapeWorksSpacePath(workspacepath) | |
IHaveCmdWorkSpacePath=0 | |
CmdWorkSpacePath="" | |
sysArgvLength=len(sys.argv) | |
print("sysArgvLength= "+str(sysArgvLength)) | |
""" | |
for i in range(sysArgvLength): | |
print i | |
myStr=sys.argv[i] | |
print ("sysArgvLength["+str(i)+"]= "+myStr) | |
UnEscapeWorksSpacePath(myStr) | |
#if sysArgvLength[i].find('////')!=-1: | |
# IHaveCmdWorkSpacePath=1 | |
# CmdWorkSpacePath=i | |
# print("ワークスペースを見つけました。CmdWorkSpacePath= "+CmdWorkSpacePath) | |
""" | |
if IHaveCmdWorkSpacePath==0: | |
print("Command workspacepath is not found !!NG") | |
#sys.exit () | |
if IHaveCmdWorkSpacePath==1: | |
print("Command workspacepath is found !!OK") | |
#Reference_importReference_Simple_workspaces_class_Instance = Anim_File_Export_class.Anim_File_Export_class() # Class export instance. | |
#Reference_importReference_Simple_workspaces_class_Instance.Reference_importReference_Simple_workspaces_all_do_method_py() | |
#print("-----------------test-------------------------") | |
#MayapyExeSimple00100 ("D////Maya/scripts/python/MotionMerge/testWorkspace/01RodLite_auto") | |
#print("-----------------test--------------------") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment