Skip to content

Instantly share code, notes, and snippets.

@skyebook
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skyebook/52f00590c3555f170b4a to your computer and use it in GitHub Desktop.
Save skyebook/52f00590c3555f170b4a to your computer and use it in GitHub Desktop.
Betaville Batch Exporter for Maya
-title "RE-Export building .DAE"
-widthHeight 100 100;
rowLayout -numberOfColumns 2;
columnLayout -adjustableColumn true;
button -label "A-------MoveTool-----------------"
-command
MoveTool;
EnterEditMode;
ctxEditMode;
button -label "B-------CenterPivot-------------"
-command
CenterPivot;
button -label "C-------SNAP-MODE ON------------"
-command
"snapMode -point true;";
button -label "1.------MOVE Pivot MANUALLY-----"
-command
EnterEditMode;
ctxEditMode;
button -label "2.------MoveToZero-Axis---------"
-command
"move -rpr 0 0 0; snapMode -point false ; ";
button -label "3.------FreezeTransformations---"
-command
FreezeTransformations;
button -label "4.------EXPORT------------------"
-command
ExportSelection;
showWindow;
// group_export.mel - Individually export all children of a selected group
// Note: Requires OpenCollada - http://opencollada.org/
// Copyright (c) 2011 Skye Book <skye.book@gmail.com>
// Released under GPL v3
// First, let's set the working units to Meters as it is usually set incorrectly
currentUnit -linear "m";
// get the relatives of the selected group (listRelatives gets only children by default)
string $children[] = `listRelatives`;
int $fileCounter=0;
for($child in $children){
// select the child
select -r $child;
float $translation[] = `xform -q -t`;
string $translateString = ("x_"+$translation[0]+"y_"+$translation[1]+"z_"+$translation[2]);
// freeze the transformations (it turns out this is not what we want to do,
// but we actually want to move the object back to the 0,0,0 point
//makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;
xform -t 0 0 0;
// export to COLLADA
file -force -options "bakeTransforms=0;relativePaths=0;copyTextures=1;exportTriangles=1;cgfxFileReferences=1;isSampling=0;curveConstrainSampling=0;removeStaticCurves=1;exportPolygonMeshes=1;exportLights=1;exportCameras=1;exportJointsAndSkin=1;exportAnimations=1;exportInvisibleNodes=0;exportDefaultCameras=0;exportTexCoords=1;exportNormals=1;exportNormalsPerVertex=1;exportVertexColors=1;exportVertexColorsPerVertex=1;exportTexTangents=0;exportTangents=0;exportReferencedMaterials=0;exportMaterialsOnly=0;exportXRefs=1;dereferenceXRefs=1;exportCameraAsLookat=0;cameraXFov=0;cameraYFov=1;doublePrecision=0;" -typ "OpenCOLLADA exporter" -pr -es (`workspace -fn`+"/"+$child+"_"+$translateString+".dae");
print $child;
print " exported\n";
$fileCounter++;
};
// provide results to console
print $fileCounter;
print " files saved to ";
print `workspace -fn`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment