Created
February 3, 2017 08:09
-
-
Save whaison/5704c79dfd86d2193ac6b2910500e81b to your computer and use it in GitHub Desktop.
FbxImport_WriteReadTrans_Z_00510.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 -*- | |
from fbx import * | |
import DebugLogger00100 | |
import WriteReadTrans_Z_00310 | |
#===================class Node========================= | |
import FbxCommon | |
#===================class Node========================= | |
class Node() : | |
def __init__(self, name, parent) : | |
self.name = name | |
self.parent = parent | |
self.children = None | |
self.type = None | |
def addChild(self, child) : | |
if not self.children : self.children = list() | |
self.children.append(child) | |
def getTypeName(fbxNode) : | |
DebugLog("190 getTypeName(fbxNode= "+str(fbxNode) ) | |
nodeAttr = fbxNode.GetNodeAttribute() | |
e = nodeAttr.GetAttributeType() | |
sType = "Unknown" | |
if FbxNodeAttribute.eNull == e : sType = "Null" | |
elif FbxNodeAttribute.eMarker == e : sType = "Marker" | |
elif FbxNodeAttribute.eSkeleton == e : sType = "Skeleton" | |
elif FbxNodeAttribute.eMesh == e : sType = "Mesh" | |
elif FbxNodeAttribute.eNurbs == e : sType = "Nurbs" | |
elif FbxNodeAttribute.ePatch == e : sType = "Patch" | |
elif FbxNodeAttribute.eCamera == e : sType = "Camera" | |
elif FbxNodeAttribute.eLight == e : sType = "Light" | |
return sType | |
def getHierarchy(fbxNode, node) : | |
num = fbxNode.GetChildCount() | |
DebugLog("205 getHierarchy(fbxNode= "+str(fbxNode)+", node.name= "+str(node.name)+")") | |
if 0 == num : return | |
for i in range(num) : | |
fbxChild = fbxNode.GetChild(i) | |
nodeChild = Node(fbxChild.GetName(), node) | |
nodeChild.type = getTypeName(fbxChild) | |
node.addChild(nodeChild) | |
getHierarchy(fbxChild, nodeChild) | |
class FbxImport_WriteReadTrans_Z_00510() : | |
Yen="\\" | |
FileName= "FbxImport_WriteReadTrans_Z_00510__Log.csv" | |
#print("HD FULL PATH =") | |
#HD_FULL_PATH=os.path.abspath(__file__) | |
#print("os.path.abspath(__file__) = " + HD_FULL_PATH) | |
FullPass_DustDataTextFile_TXT= "D:"+Yen+"vs"+Yen+"py"+Yen+FileName | |
Yen="\\" | |
#IMPORT_FBX_FileName="Solder_Model_ASCII_2016_2017_motion00200.fbx" | |
IMPORT_FBX_FileName="walkTest_00200_Only_Root_And_C_Pelvis_ASCII.fbx" | |
FBX_FILE_PATH_AND_NAME_AND_EXT= "D:"+Yen+"vs"+Yen+"py"+Yen+IMPORT_FBX_FileName | |
EXPORT_FBX_FILENAME="walkTest_00200_Only_Root_And_C_Pelvis_ASCII_Fbx_Trans_Z_00510_.fbx" | |
FullPass_EXPORT_FBX_FILENAME= "D:"+Yen+"vs"+Yen+"py"+Yen+EXPORT_FBX_FILENAME | |
# Propaty End======================================== | |
# Method Start======================================== | |
def FbxImport_WriteReadTrans_Z_00510(self): | |
print ("==========================FbxImport_WriteReadTrans_Z_00510()=========================================") | |
#DebugLog_init(FullPass_DustDataTextFile_TXT,"--------none--------"): | |
#DebugLog_init() | |
def loadFile(self, filename) : | |
self.filename = filename | |
self.root = None | |
self.load() | |
def load(self) : | |
print ("loading ... self.filename= "+self.filename) | |
#print "loading : %s"%self.filename | |
manager = FbxManager.Create() | |
ios = FbxIOSettings.Create(manager, IOSROOT) | |
manager.SetIOSettings(ios) | |
importer = FbxImporter.Create(manager, "") | |
fbxImportSuccesBool=importer.Initialize(self.filename, -1, manager.GetIOSettings()) | |
DebugLog("fbxImportSuccesBool="+str(fbxImportSuccesBool)) | |
if not fbxImportSuccesBool: | |
print ("==============Failed to load file.=============="+self.filename) | |
return | |
scene = FbxScene.Create(manager, "MyScene") | |
importer.Import(scene) | |
#importer.Initialize() | |
fbxRoot = scene.GetRootNode() | |
self.root = Node(fbxRoot.GetName(), None) | |
getHierarchy(fbxRoot, self.root) | |
######GetMesh(self.root) | |
#GetKeyCurve(importer,scene)#198 200 Line | |
print ("==============Succeeded to load file.========="+self.filename) | |
#========================================================================================================================== | |
#=================================================== EXPORT ======================================================== | |
#========================================================================================================================== | |
Export_Result = FbxCommon.SaveScene(manager, scene, self.FullPass_EXPORT_FBX_FILENAME) | |
if Export_Result==0: | |
print("Export_Result==0 NG !!!!!!!!!!!!!!!!!!!!!!!!!!!cant out file!!!!!!!!!!!!!!!!!!!!! ") | |
else: | |
print("Export_Result==1 OK !!!!!!!!!!!!!!!!!!!!!!!!!! out put File self.FullPass_EXPORT_FBX_FILENAME= "+self.FullPass_EXPORT_FBX_FILENAME) | |
#============================================================================================================================= | |
#============================================================================================================================= | |
#============================================================================================================================= | |
print ("==============Destroy All=========") | |
importer.Destroy() | |
def FbxImport_WriteReadTrans_Z_00510(self): | |
print("FbxImport_WriteReadTrans_Z_00510_Start............. filepath = "+str(filepath)) | |
def Samething(self): | |
print("014 FbxImport_WriteReadTrans_Z_00510 Samething()") | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
#//////////////////////////////////// Class Unit Test ///////////////////////////////////////////// | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
def getClassName(self): | |
print( u"className= " + self.__class__.__name__) | |
return self.__class__.__name__ | |
#=============================Code Start=============================================== | |
print(" Code Start="+__name__) | |
Debug_Instance=DebugLogger00100.DebugLogger00100() | |
def DebugLogStart(): | |
#print("DebugStr = "+ DebugStr) | |
Debug_Instance.DebugLogStart() | |
def DebugLog(DebugStr): | |
print("DebugStr = "+ DebugStr) | |
Debug_Instance.DebugLog(" 88 Logger >>>>>>>>"+DebugStr); | |
FBX_trans_z_Instance = FbxImport_WriteReadTrans_Z_00510() # Class export instance. | |
print(" FbxImport_WriteReadTrans_Z_00510 Class __name__="+__name__) | |
WriteReadTrans_ZInstance=WriteReadTrans_Z_00310.WriteReadTrans_Z_00310() | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
#//////////////////////////////////// Class Unit Test ///////////////////////////////////////////// | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
def StartMainLine(Debug,WriteReadTrans_Z_Instance,FBX_trans_z_Instance): | |
print(" ========================== StartMainLine ========================== ") | |
print(" ========================== StartMainLine ========================== ") | |
print(" ========================== StartMainLine ========================== ") | |
DebugLogStart() | |
FBX_trans_z_Instance.Samething() | |
FBX_trans_z_Instance.loadFile(FBX_trans_z_Instance.FBX_FILE_PATH_AND_NAME_AND_EXT) | |
print(" ========================== END StartMainLine ========================== ") | |
print(" ========================== END StartMainLine ========================== ") | |
print(" ========================== END StartMainLine ========================== ") | |
print(" ========================== END StartMainLine ========================== ") | |
#DebugLog (u"__name__==self.__class__.__name__ Same!! File Test") | |
#DebugLog (u"=============Simple Single Class Unit Test Start==========") | |
#Instance.FbxImport_WriteReadTrans_Z_00510() #Call Method | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
#//////////////////////////////////// Class Unit Test ///////////////////////////////////////////// | |
#////////////////////////////////////////////////////////////////////////////////////////////////// | |
if(__name__ == FBX_trans_z_Instance.getClassName()): | |
print (u"============= 01 Simple Single Class Unit Test Start==== Instance.getClassName() = "+FBX_trans_z_Instance.getClassName()+" =====") | |
#StartMainLine(Debug_Instance,WriteReadTrans_ZInstance,FBX_trans_z_Instance) | |
elif(__name__ == "FbxImport_WriteReadTrans_Z_00510"): | |
print (u"============= 02 Simple Single Class Unit Test Start===== StartMainLine =====") | |
#StartMainLine(Debug_Instance,WriteReadTrans_ZInstance,FBX_trans_z_Instance) | |
#Instance.loadFile(FBX_FILE_PATH_AND_NAME_AND_EXT) | |
elif(__name__ == "__main__"): | |
print (u"============= 03 Simple Single Class Unit Test Start===== __main__ =====") | |
StartMainLine(Debug_Instance,WriteReadTrans_ZInstance,FBX_trans_z_Instance) | |
else: | |
print (u"__name__!=self.__class__.__name__ Othor File Import") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment