[maya][python]scriptEditorInfoでスクリプトエディタの内容のログの最後の行を取る

Take the last line of the log in the contents of the script editor

#!/usr/bin/env python
# -*- coding: utf-8 -*-
workSpaceDir=cmds.workspace( q=True, rootDirectory=True )
print("workSpaceDir= "+workSpaceDir)
historyFilename=workSpaceDir+'scriptEditorInfo_tempHistoryLog7.txt'
print("historyFilename= "+historyFilename)
cmds.scriptEditorInfo(input="")
cmds.scriptEditorInfo( historyFilename=historyFilename, writeHistory=True )

print("----startLog00700---")
#-----この間にUSD prim を選択させてみたい。 ----------
#------難しいかな??
#-----この間にUSD prim を選択させてみたい。 ----------
import codecs
fin  = codecs.open(historyFilename, 'r', 'shift_jis')
lineCount=0
lineArr=[]
for line in fin:
    #print("lineNum:"+str(lineCount)+" lineStr:"+line)
    lineCount=lineCount+1
    lineArr.append(line)
#fout = codecs.open('sjis.txt', 'w', 'shift_jis')
#fin_str=str(fin)
lineArr_len=len(lineArr)
print("lineArr_len= "+str(lineArr_len))
LastLine_Str=lineArr[lineArr_len-1]
print("LastLine_Str= "+LastLine_Str)

cmds.scriptEditorInfo(input="")
cmds.scriptEditorInfo( historyFilename=historyFilename, writeHistory=False )

print("----NotLoged----")

[maya]maya_usdでシーンにある選択したステージをmaya_usd apiのstageとして取得するには?

How to get the selected stage in the scene in maya_usd as the stage in maya_usd api?

import maya.cmds as cmds

def get_stage(stagePath):
    import mayaUsd.ufe
    #stagePath="|stage1|stageShape1"
    #stage = mayaUsd.ufe.getStage("|stage1|stageShape1")
    stage = mayaUsd.ufe.getStage(stagePath)
    print("stage= "+str(stage))
    # レイヤーを取得
    layer = stage.GetRootLayer()
    print("layer= "+str(layer))

def get_selected_maya_usd_stage():
    selectedlist=cmds.ls(sl=True,long=1)
    print("selectedlist= "+str(selectedlist))
    selectedZero=selectedlist[0]
    selectedZeroType=cmds.objectType( selectedZero )
    print("selectedZeroType= "+str(selectedZeroType))
    
    stagePath=""
    if(str(selectedZeroType)=="mayaUsdProxyShape"):
        stagePath=selectedZero
        get_stage(stagePath)
    elif(str(selectedZeroType)=="transform"):
        stagePath="|stage"+stageNumStr+"|stageShape"+stageNumStr
        get_stage(stagePath)
    else:
        print("not stage!!!!")
        
get_selected_maya_usd_stage()

OUTPUT

selectedlist= ['|stage5']
selectedZeroType= transform
stage= Usd.Stage.Open(rootLayer=Sdf.Find('anon:000002B5C8EA5570:anonymousLayer1'), sessionLayer=Sdf.Find('anon:000002B5C8EA5870:anonymousLayer1-session.usda'), pathResolverContext=Ar.DefaultResolverContext())
layer= Sdf.Find('anon:000002B5C8EA5570:anonymousLayer1')

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

selectedlist= ['|stage5|stageShape5']
selectedZeroType= mayaUsdProxyShape
stage= Usd.Stage.Open(rootLayer=Sdf.Find('anon:000002B5C84B1070:anonymousLayer1'), sessionLayer=Sdf.Find('anon:000002B5C84B1670:anonymousLayer1-session.usda'), pathResolverContext=Ar.DefaultResolverContext())
layer= Sdf.Find('anon:000002B5C84B1070:anonymousLayer1')

参考URL
https://github.com/Autodesk/maya-usd/issues/1046

[unrealenghine,photoshop]HDRは32bitなので16bitに変換しないとPNGに保存できない、8bitに変換しないと TGA に保存できない

Can Not HDR Traslate To TGA even if CopySave

 function step_8bit(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putInteger(cTID('Dpth'), 8);
    var desc2 = new ActionDescriptor();
    desc2.putInteger(cTID('Vrsn'), 6);
    desc2.putEnumerated(cTID('Mthd'), sTID("hdrToningMethodType"), sTID("hdrtype4"));
    desc2.putDouble(cTID('Rds '), 7.68);
    desc2.putDouble(cTID('Thsh'), 0.52959457138863);
    desc2.putDouble(cTID('Cntr'), 1);
    desc2.putDouble(cTID('Strt'), 20);
    desc2.putDouble(cTID('Dtl '), 30);
    desc2.putBoolean(cTID('Smoo'), false);
    var desc3 = new ActionDescriptor();
    desc3.putString(cTID('Nm  '), "初期設定");
    var list1 = new ActionList();
    var desc4 = new ActionDescriptor();
    desc4.putDouble(cTID('Hrzn'), 0);
    desc4.putDouble(cTID('Vrtc'), 0);
    list1.putObject(cTID('CrPt'), desc4);
    var desc5 = new ActionDescriptor();
    desc5.putDouble(cTID('Hrzn'), 255);
    desc5.putDouble(cTID('Vrtc'), 255);
    list1.putObject(cTID('CrPt'), desc5);
    desc3.putList(cTID('Crv '), list1);
    desc2.putObject(sTID("classFXShapeCurve"), cTID('ShpC'), desc3);
    desc2.putBoolean(sTID("deghosting"), false);
    desc1.putObject(cTID('With'), sTID("hdrOptions"), desc2);
    executeAction(sTID('convertMode'), desc1, dialogMode);
  };  

  //save TGA  (Can Not  HDR Traslate To TGA even if CopySave)
  function step4_save_tga(savePath){
  step_8bit();
  SaveOptions = new TargaSaveOptions();     
  TargaSaveOptions.alphaChannels = true; //include alpha channels, change to false for none    
  TargaSaveOptions.resolution = TargaBitsPerPixels.TWENTYFOUR; //options of SIXTEEN or THIRTYTWO 
  TargaSaveOptions.rleCompression = true; //false for no compression
  var saveFile = File(savePath); 
  app.activeDocument.saveAs(saveFile, TargaSaveOptions, true,Extension.LOWERCASE);      
  }; 

//---------------------------------------------------------------------------------
function step1_16bit(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putInteger(cTID('Dpth'), 16);
    var desc2 = new ActionDescriptor();
    desc2.putInteger(cTID('Vrsn'), 6);
    desc2.putEnumerated(cTID('Mthd'), sTID("hdrToningMethodType"), sTID("hdrtype4"));
    desc2.putDouble(cTID('Rds '), 7.68);
    desc2.putDouble(cTID('Thsh'), 0.52959457138863);
    desc2.putDouble(cTID('Cntr'), 1);
    desc2.putDouble(cTID('Strt'), 20);
    desc2.putDouble(cTID('Dtl '), 30);
    desc2.putBoolean(cTID('Smoo'), false);
    var desc3 = new ActionDescriptor();
    desc3.putString(cTID('Nm  '), "初期設定");
    var list1 = new ActionList();
    var desc4 = new ActionDescriptor();
    desc4.putDouble(cTID('Hrzn'), 0);
    desc4.putDouble(cTID('Vrtc'), 0);
    list1.putObject(cTID('CrPt'), desc4);
    var desc5 = new ActionDescriptor();
    desc5.putDouble(cTID('Hrzn'), 255);
    desc5.putDouble(cTID('Vrtc'), 255);
    list1.putObject(cTID('CrPt'), desc5);
    desc3.putList(cTID('Crv '), list1);
    desc2.putObject(sTID("classFXShapeCurve"), cTID('ShpC'), desc3);
    desc2.putBoolean(sTID("deghosting"), false);
    desc1.putObject(cTID('With'), sTID("hdrOptions"), desc2);
    executeAction(sTID('convertMode'), desc1, dialogMode);
  };

  //save Png 
  function step4_save(savePath,enabled, withDialog) {
  step1_16bit();
  var file_obj = new File(savePath);
  var png_opt = new PNGSaveOptions();
  png_opt.interlaced = false;
  var savedDisplayDialogs = app.displayDialogs;
  app.displayDialogs = DialogModes.NO;
  activeDoc=app.activeDocument;
  app.activeDocument.saveAs(file_obj, png_opt, true, Extension.LOWERCASE);
  
  }
//---------------------------------------------------------------------------------


  // save HDR (HDR to HDR)
  function step4_save(savePath,enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putString(cTID('As  '), "Radiance");
    desc1.putPath(cTID('In  '), new File(savePath));
    desc1.putInteger(cTID('DocI'), 70);
    desc1.putBoolean(cTID('LwCs'), true);
    executeAction(sTID('save'), desc1, dialogMode);
  };

参考

Targa形式で保存する

http://www.openspc2.org/book/PhotoshopCC2014/easy/save/010/index.html

[maya]Python3 Pyside2 _showProgressDialog qApp.processEvents() NameError: name ‘qApp’ is not defined

[maya]Python3 Pyside2 _showProgressDialog qApp.processEvents() NameError: name ‘qApp’ is not defined の解決方法

class DF_TalkUI(QMainWindow):


    def __init__(self, parent = None):
        super(DF_TalkUI, self).__init__(parent)
        self.setObjectName("DF_Talk_Window")
        self.setWindowTitle("DF Talk Window")
        self._initUI()
        self.errorDialog = QErrorMessage(self) # QErrorMessageインスタンスの保持

    def setupApp(self,app):
        self.app=app
    def _initUI(self):
        wrapper = QWidget()
        self.setCentralWidget(wrapper)

        mainLayout = QVBoxLayout()
        wrapper.setLayout(mainLayout)


        #-----------------------------------------------------------------------
        # sixth row
        #-----------------------------------------------------------------------
        sixthHorizontalArea = QHBoxLayout()
        sixthHorizontalArea.setSpacing(20)
        mainLayout.addLayout(sixthHorizontalArea)



        progressDialogBtn = QPushButton("Progress Dialog")
        sixthHorizontalArea.addWidget(progressDialogBtn)
        progressDialogBtn.clicked.connect(self._showProgressDialog)

        fileDialogBtn = QPushButton("File Dialog")
        sixthHorizontalArea.addWidget(fileDialogBtn)
        fileDialogBtn.clicked.connect(partial(QFileDialog.getOpenFileName, self, "File Select", options = QFileDialog.DontUseNativeDialog))

        #-----------------------------------------------------------------------
        # seventh row
        #-----------------------------------------------------------------------


    def _makeHorizontalLine(self):
        hline = QFrame()
        hline.setFrameShape(QFrame.HLine)
        hline.setFrameShadow(QFrame.Sunken)
        return hline


    def _showProgressDialog(self):
        #----------------------------------------------------
        qApp = self.app
        #----------------------------------------------------
        #QProgressDialog表示スロット
        
        max = 100
        progressDialog = QProgressDialog("Progress...", "Cancel", 0, max, self)
        progressDialog.setWindowTitle("Progress Dialog")

        for count in range(max+1):
            qApp.processEvents()

            if progressDialog.wasCanceled():
                break

            progressDialog.setValue(count)
            progressDialog.setLabelText("Progress... %d %%" % count)
            time.sleep(0.1)



def start(app):
    maya_win = get_maya_pointer()
    ui = DF_TalkUI(parent = maya_win)
    ui.setupApp(app)
    ui.show()
    return ui

print("__name__= "+str(__name__))
if __name__ == '__main__':

    app = QApplication.instance()
    if app is None:
        app = QApplication([])
    ui = start(app)
    app.exec_()

[maya]MELからPythonへ変数を渡す際にエンコードを変える MEL to Python Variable

global proc BuildMenuItems(string $menuName){
    python("import buildMenu.buildMenuItems as bm");
	python("import codecs");
	
	python("import sys");
    python("print('sys.getdefaultencoding= '+sys.getdefaultencoding())");
	
	print("$menuName= "+$menuName+"\n");
	string $menuNameA = python("menuNameA='"+$menuName+"'");
	print("$menuNameA= "+$menuNameA+"\n");
    python("print('menuNameA= '+str(menuNameA))");
	
	string $menuNameUTF8 = python("menuNameUTF8='"+$menuName+"'.encode('utf_8')");
	print("$menuNameUTF8= "+$menuNameUTF8+"\n");
    python("print('menuNameUTF8= '+str(menuNameUTF8))");
    
	string $menuNameCP932 = python("menuNameCP932='"+$menuName+"'.encode('cp932')");
	print("$menuNameCP932= "+$menuNameCP932+"\n");
	python("print('menuNameCP932= '+str(menuNameCP932))");
	
	string $menuNameDecodeUTF8 = python("menuNameDecodeUTF8=b'"+$menuName+"'.decode('utf-8')");
	print("$menuNameDecodeUTF8= "+$menuNameDecodeUTF8+"\n");
    python("print('menuNameDecodeUTF8= '+str(menuNameDecodeUTF8))");
    
	string $menuNameDecodeCP932 = python("menuNameDecodeCP932=b'"+$menuName+"'.decode('cp932')");
	print("$menuNameDecodeCP932= "+$menuNameDecodeCP932+"\n");
	python("print('menuNameDecodeCP932= '+str(menuNameDecodeCP932))");
	
    //python("bm.main('u" + $menuName + "')");
    //python("bm.main(menuNameDecodeCP932)");
    python("bm.main()");
}

[maya]エクセルをcsv出力してPythonでその日本語unicode型オブジェクトをcp932で出力すると日本語が表示される。

[maya]エクセルをcsv出力してPythonでその日本語unicode型オブジェクトをcp932で出力すると日本語が表示される。

u3042unicodeオブジェクト
https://www.kabipan.com/computer/python/unicode.html

# -*- coding: cp932 -*-

import pymel.core as pm
import pymel.tools.mel2py as mel2py
import re
import math
import random
workspaceDir=cmds.workspace( q=True, dir=True )
workspaceDir="D:/Projects/mocap_data/"
print("workspaceDir= "+workspaceDir)

csvPath=workspaceDir+"csv_utf8.csv"
csvPath=workspaceDir+"csv.csv"
csvPath_out=workspaceDir+"csv_out.csv"
print("csvPath= "+csvPath)
import sys
import codecs

fin  = codecs.open(csvPath, 'r', 'utf_8')    
    
print("fin= "+str(fin))
s = fin.read()
strData=s.rstrip()
#print("strData= "+strData)

#u3042はunicodeオブジェクト https://www.kabipan.com/computer/python/unicode.html

dict={}
slineArr=strData.split("\r")
slineArr_len=len(slineArr)
print("slineArr_len= "+str(slineArr_len))
print("slineArr= "+str(slineArr))
for line in slineArr:
    csvline_arr=line.split(",")
    print("csvline_arr= "+str(csvline_arr))
    try:
        FMNum= csvline_arr[1]
        #print("FMNum= "+str(FMNum))
        sys.stdout.write("FMNum= "+csvline_arr[1].encode('cp932')+"\n")
        
        motionName=csvline_arr[2]
        sys.stdout.write("motionName= "+csvline_arr[2].encode('cp932')+"\n")
        
        dict[FMNum] = motionName
        #print("motionName= "+str(motionName))
        
    except OSError:
        pass
    
print("dict= "+str(dict))

もっと

# -*- coding: utf-8 -*- 
from maya import cmds 
import pymel.core as pm 


def Simple_Avi_Export():
    topNodes=cmds.ls(assemblies=1,type='transform')
    print("topNodes= "+str(topNodes))
    for node in topNodes:
        try:
            cmds.setAttr(node+".visibility", 0)
        except RuntimeError:
            pass
            
    model=cmds.ls('*:*:model')
    print("model= "+str(model))
    cmds.setAttr(model[0]+".visibility", 1)
    model_Child=cmds.ls(model[0],dag=1)
    for node in model_Child:
        try:
            cmds.setAttr(node+".visibility", 1)
        except RuntimeError:
            pass
    
    #pm.setAttr("magF_Rig:secondaryJointCtrl.visibility", 0)
    cmds.select('export_sets_mot', r=1, ne=1)
    export_sets_mot_childs = cmds.listConnections( 'export_sets_mot', destination=True )
    print("export_sets_mot_childs[0]="+export_sets_mot_childs[0])
    childName=export_sets_mot_childs[0]
    print("childName="+childName)
    
    startF=cmds.getAttr(childName+".startF")
    endF=cmds.getAttr(childName+".endF")
    fbxName=cmds.getAttr(childName+".fbxName")
    exportPath=cmds.getAttr(childName+".exportPath ")
    print startF
    print endF
    print fbxName
    print exportPath
    
    sceneName=cmds.file( q=True, sceneName=True,shortName=True )
    root_ext_pair = os.path.splitext(sceneName)
    sceneNameonly=root_ext_pair[0]
    
    videoOutPath=exportPath+"/"+sceneNameonly+fbxName+".avi"
    videoOutPath="video"+"/"+sceneNameonly+fbxName+".avi"
    print("videoOutPath= "+videoOutPath)
    cmds.playblast(fp=4, clearCache=1, format='avi', sequenceTime=0, showOrnaments=1, percent=50, filename=videoOutPath, viewer=1, startTime=startF, endTime=endF, quality=70, compression="none" ,forceOverwrite=1)
    
#Simple_Avi_Export()


def dirAllOpenAndExport(dir_path):
    import os
    import re
    for current_dir, sub_dirs, files_list in os.walk(dir_path): 
      for file_name in files_list: 
        fullpath=os.path.join(current_dir,file_name)
        fullpath=os.path.abspath(fullpath)
        fullpath=re.sub(r'\\', '/', fullpath)
        print("fullpath= "+fullpath)
        cmds.file(fullpath, ignoreVersion=1, typ="mayaAscii", options="v=0;", o=1, f=1)
        Simple_Avi_Export()

dirAllOpenAndExport("D:/Projects/" )

そのほかの例

# -*- coding: cp932 -*-

import pymel.core as pm
import pymel.tools.mel2py as mel2py
import re
import math
import random
import sys
import codecs

workspaceDir=cmds.workspace( q=True, dir=True )
workspaceDir="D:/Projects/"
print("workspaceDir= "+workspaceDir)
csvPath_out=workspaceDir+"csv_out.csv"
csvPath=workspaceDir+"csv_utf8.csv"
csvPath=workspaceDir+"csv.csv"

print("csvPath= "+csvPath)

fin  = codecs.open(csvPath, 'r', 'utf_8')    
    
print("fin= "+str(fin))
s = fin.read()
strData=s.rstrip()
#print("strData= "+strData)

#u3042はunicodeオブジェクト https://www.kabipan.com/computer/python/unicode.html

dict={}
slineArr=strData.split("\r")
slineArr_len=len(slineArr)
print("slineArr_len= "+str(slineArr_len))
print("slineArr= "+str(slineArr))
for line in slineArr:
    csvline_arr=line.split(",")
    print("csvline_arr= "+str(csvline_arr))
    try:
        FMNum= csvline_arr[1]
        #print("FMNum= "+str(FMNum))
        #sys.stdout.write("FMNum= "+csvline_arr[1].encode('cp932')+"\n")
        
        motionName=csvline_arr[2]
        #sys.stdout.write("motionName= "+csvline_arr[2].encode('cp932')+"\n")
        
        dict[FMNum] = motionName
        #print("motionName= "+str(motionName))
        
    except OSError:
        pass
    
print("dict= "+str(dict))



#---------------------------------------------------------------------------------
# -*- coding: utf-8 -*- 
from maya import cmds 
import pymel.core as pm 


def getKeyFrame_3way():
    
    playbackOptions_query_minTime=int(cmds.playbackOptions(minTime=1, query=1))
    print("playbackOptions_query_minTime= "+str(playbackOptions_query_minTime))
    playbackOptions_query_maxTime=int(cmds.playbackOptions(query=1, maxTime=1))
    print("playbackOptions_query_maxTime= "+str(playbackOptions_query_maxTime))

    selected=cmds.ls(selection=1)

    cmds.select("*")

    findKeyframe_which_first=int(pm.findKeyframe(which='first'))
    print("findKeyframe_which_first= "+str(findKeyframe_which_first))
    findKeyframe_which_last=int(pm.findKeyframe(which='last'))
    print("findKeyframe_which_last= "+str(findKeyframe_which_last))

    cmds.select(selected)
    AllCurveStart=float(AllCurve_Start_or_End(0))
    AllCurveEnd=float(AllCurve_Start_or_End(1))
    print("AllCurveStart= "+str(AllCurveStart))
    print("AllCurveStart= "+str(AllCurveStart))
Start_Or_End=""
#global 
animCurve_string_arr = []
#global 

def AllCurve_Start_or_End(Start_Or_End):
    
    animCurve_string_arr=cmds.ls(type=['animCurveTL', 'animCurveTU', 'animCurveTA', 'animCurveTT'])

    keyframetime_arr=cmds.keyframe(animCurve_string_arr, query=1, timeChange=1)

    old_min=0.0
    old_max=0.0
    for i in range(0,len(keyframetime_arr)):
        if i == 0:
            old_min=keyframetime_arr[i]

            old_max=keyframetime_arr[i]

            
        if keyframetime_arr[i]<old_min:
            old_min=keyframetime_arr[i]
            
        if keyframetime_arr[i]>old_max:
            old_max=keyframetime_arr[i]
            
        
    return_float=0.0

    return_float=old_min
    if Start_Or_End == 0:
        return_float=old_min
        
    else:
        return_float=old_max
        
    return return_float

#getKeyFrame_3way()

#----------------------------------------------------------------------------------


from maya import cmds 
import pymel.core as pm 


def Simple_Avi_Export(mayaPath):
    #onColorMgtOutputEnabledCheckBoxChange colorManagementOutputEnableCheckBoxRenderSettings 0;
    #onColorMgtOutputChanged colorManagementOutputTransformOptionMenuRenderTypeSettings colorManagementOutputTransformOptionMenuRenderSettings colorManagementOutputEnableCheckBoxRenderSettings 0;
    #import maya.mel as mel

    #mel.eval('onColorMgtOutputEnabledCheckBoxChange colorManagementOutputEnableCheckBoxRenderSettings 0;')
    #mel.eval('onColorMgtOutputChanged colorManagementOutputTransformOptionMenuRenderTypeSettings colorManagementOutputTransformOptionMenuRenderSettings colorManagementOutputEnableCheckBoxRenderSettings 0;')
    pm.setAttr("persp.translateX", 327)
    pm.setAttr("persp.translateY", 313)
    pm.setAttr("persp.translateZ", 326)

    pm.setAttr("perspShape.centerOfInterest", 463)
    
    topNodes=cmds.ls(assemblies=1,type='transform')
    print("topNodes= "+str(topNodes))
    for node in topNodes:
        try:
            cmds.setAttr(node+".visibility", 0)
        except RuntimeError:
            pass
            
    model=cmds.ls('*:model')
    print("model= "+str(model))
    cmds.setAttr(model[0]+".visibility", 1)
    model_Child=cmds.ls(model[0],dag=1)
    for node in model_Child:
        try:
            cmds.setAttr(node+".visibility", 1)
        except RuntimeError:
            pass
    
    #pm.setAttr("magF_Rig:secondaryJointCtrl.visibility", 0)
    
    startF=int(cmds.playbackOptions(minTime=1, query=1))
    print("startF= "+str(startF))
    endF=int(cmds.playbackOptions(query=1, maxTime=1))
    print("endF= "+str(endF))
    
    #sceneName=cmds.file( q=True, sceneName=True,shortName=True )
    sceneName = os.path.basename(mayaPath)
    root_ext_pair = os.path.splitext(sceneName)
    sceneNameonly=root_ext_pair[0]
    
    #mayaPath=cmds.file( q=True, sceneName=True,shortName=False )
    print("mayaPath= "+mayaPath)
    mayaPath_Arr=mayaPath.split("/")
    mayaPath_Arr_len=len(mayaPath_Arr)
    last1dirName=mayaPath_Arr[mayaPath_Arr_len-2]
    print("last1dirName= "+last1dirName)
    last2dirName=mayaPath_Arr[mayaPath_Arr_len-3]
    print("last2dirName= "+last2dirName)
    
    motionName=""
    if(sceneNameonly in dict):
        motionName=dict[sceneNameonly]
        sys.stdout.write("motionName= "+motionName.encode('cp932')+"\n")
    
        motionName932=motionName.encode('cp932')
        print("motionName932= "+motionName932)
        #motionNameUTF8=motionName.encode('utf_8')
        #print("motionNameUTF8= "+motionNameUTF8)
    videoOutPath="/"+sceneNameonly+".avi"
    videoOutPath=u"D:/Projects/mocap_data"+"/"+last2dirName+"/"+sceneNameonly+u"__"+motionName+u"__"+u".avi"
    print("videoOutPath= "+videoOutPath)
    cmds.playblast(fp=4, clearCache=1, format='avi', sequenceTime=0, showOrnaments=1, percent=50, filename=videoOutPath, viewer=1, startTime=startF, endTime=endF, quality=70, compression="none" ,forceOverwrite=1)
    
#Simple_Avi_Export()


def dirAllOpenAndExport(dir_path):
    import os
    import re
    for current_dir, sub_dirs, files_list in os.walk(dir_path): 
      for file_name in files_list: 
        fullpath=os.path.join(current_dir,file_name)
        fullpath=os.path.abspath(fullpath)
        fullpath=re.sub(r'\\', '/', fullpath)
        print("fullpath= "+fullpath)
        
        root_ext_pair = os.path.splitext(fullpath)
        ExtentionOnly=root_ext_pair[1]
        if(ExtentionOnly==".ma"):
            
            #cmds.file(fullpath, ignoreVersion=1, typ="mayaAscii", options="v=0;", o=1, f=1)
            cmds.file(new=1, f=1)
            cmds.file(fullpath, ignoreVersion=1, type="mayaAscii", namespace="ref", r=1, gl=1, mergeNamespacesOnClash=False, options="v=0;")
            
            Simple_Avi_Export(fullpath)
dirAllOpenAndExport("D:/Projects/mocap_data/" )

#AdvancedLocomotionSystem #UE4 #UE4Study #NierAutomata2B #2B #UE4 #humanoid rig #VirtualbornSetting

Nier Automata 2B Data is here

[Download Now] 2B Nier:Automata (original model) – DeviantArt

https://www.deviantart.com/shinylightbulb/art/Download-Now-2B-Nier-Automata-original-model-670383209

XPS.XPS convert in Blender

XPS tools 2.0.2 (for Blender 2.80+) by johnzero7 on DeviantArt

https://www.deviantart.com/johnzero7/journal/XPS-tools-2-0-2-for-Blender-2-80-834572824

OLD Blender2.80 Download is here

https://download.blender.org/release/Blender2.80/

export xps to fbx

open in Maya

1,chengeJoint Name and Mesh Name.

2,load UE4_Mannequin_Female.fbx from UE4.26

3,メッシュフォルムが崩れないようにできるだけ回転のみで2BjointをUE4ジョイントに合わせる。

4,2Bジョイントとメッシュのグループを複製してその形状のメッシュを作成

5,2Bジョイントのジョイントを消して変形された2Bメッシュを残す

6, 残った2BメッシュをUE4ジョイントとグループ化

7,SkinBind

8,SkinWeightCopy 2BJoint Mesh > New2B UE4 Joint Mesh

Export fbx

UE4 humanoid rig Virtual born Setting

Select root Add Virtual Bone >root Name:Curves
Select Curves Add Virtual Bone >root Name:ik_foot_root
Select ik_foot_root Add Virtual Bone >foot_r Name:ik_foot_r
Select ik_foot_root Add Virtual Bone >foot_l Name:ik_foot_l

Select ik_foot_r Add Virtual Bone >foot_r Name:ik_foot_r_offset
Select ik_foot_l Add Virtual Bone >foot_l Name:ik_foot_l_offset

Select ik_foot_r Add Virtual Bone >calf_r Name:ik_knee_target_r
Select ik_foot_l Add Virtual Bone >calf_l Name:ik_knee_target_l

Select root Add Virtual Bone >foot_r Name:foot_target_r
Select root Add Virtual Bone >foot_l Name:foot_target_l

Option>Show Retargeting Option
Recursively Set Translation Retargeting Skeleton
root > Translation Retargeting go to>Animation
Pelvis > Translation Retargeting go to>Animation

ここでALS_AnimBPを右クリックしてリターゲット
ALS> N2Bで置換しつつリターゲット

How to integrate MetaHumans with ALSV4 | Part 1/3 | UE4
18:04/35:47
ALS_N2B_CharactorBP>EventGraph
ParentTick > Update Coloring System Disconnect
ParentTick x Update Coloring System

ALS_N2B_CharactorBP>Construction Script
Set MatserPose Component > Set Dynamic Material Disconnect
Set MatserPose Component x Set Dynamic Material

How to integrate MetaHumans with ALSV4 | Part 1/3 | UE4
24:26/35:47

N2B_AnimBP Open
Window>FindResult input ik_foot
FindResult Replace All hand
ik_foot_r > VB ik_foot_r
ik_foot_l > VB ik_foot_l
ik_foot_root >VB ik_foot_root

goto AnimGraph
Go to Left Side OverLayLayer >Overlay States> Feminine >Copy All
Back Overlay States>Default>Past

Retarget > ALS_Montage Action All Select
Replace
ALS >N2B
Retarget

Open ALS_N2B_CharactorBP
window>FindResult
“switch on overlay state”
Result2,3,4,5, open
ALS_Montage >N2B_Montage

膝がかなり離れている場合
If your knees are far apart
N2B_AnimBP >AnimGraph>Linked Anim Layer Foot IK
Modify Knee Targets Comment
Transform(Modify)Bone >Translation 20 10 5
Transform(Modify)Bone >Translation -20 -10 -5

Montage is not good high root motion
FBX export And Delete root joint keyframe animation
N2B_N_LandRoll_F
N2B_N_Mantle_1m_LH
N2B_N_Mantle_1m_RH
N2B_N_Mantle_2m
(mean ‘s root joint is Go to Change “SK_Manequin_Female” Then Can’t Delete UE4 Root Motion)

AdvancedLocomotion用のキャラのスキニングがやっとできてきた。

結局、無理なポーズはmayaに読み込んでそのポーズでスキニング調整しないとだめだった。

これでもできてるほうでもっとぐちゃぐちゃになってたので。

パンツの方のスキニングやらサイズやら調整したが、

からだのお尻のスキニングがぐちゃぐちゃだったからどうやってもだめだった。

お尻らへんの頂点を選択してスキンウェイトハンマーしたら変な形状を保とうとしなくなって

そのスキニングをパンツへコピーしたらできた。