Saturday, July 2, 2016

FBX batch export for UE4 (with saved PIVOT)


This simple MEL script will :

  • take the name of the each mesh group (collision + mesh) 
  • snap it to zero world zero location 
  • export it as fbx (using your last export settings)
  • and zero out you translations after (assuming your transformation were freezed in first place)


string $fbxPath = "C:/Users/yourname/Desktop/"; ///make sure it's / not \
///^^^type the path to files here^^^///

string $selection[] = `ls -sl`; /// List selected

for($item in $selection) {
    
string $fullTempPath = $fbxPath + $item ; ///create full path + name of the group

select -r $item;  ///have the item selected
move -rpr 0 0 0 ;  ///move to 0 position
SnapToGrid; dR_enterForSnap;
file -force -options "groups=1;ptgroups=1;materials=0;smoothing=1;normals=1" -typ "FBX export" -pr -es $fullTempPath; ///save the file
setAttr ($item +".translateZ") 0;
setAttr ($item +".translateX") 0;
setAttr ($item +".translateY") 0; /// move back to right position

}

-this way you can organize all of your repetitive meshes in one scene , laying them out anywhere on the grid.Making changes later on would be easier assuming the path of your meshes didn't change , just by clicking Reimport buttom in UE4