Search Unity

maya export many objects from same scene as differnt files

Discussion in 'Asset Importing & Exporting' started by jin76, Jun 10, 2012.

  1. jin76

    jin76

    Joined:
    Mar 4, 2010
    Posts:
    364
    hey everyone

    In my scene, i have dozens of little pieces and i would like to export each one of the pieces as different fbx files. Is there any script to that would help to speed up the process , instead of me clicking every individual file and hitting export selected as that would take hours.

    If anyone can help let me know it would be great.

    Jin
     
  2. Photon-Blasting-Service

    Photon-Blasting-Service

    Joined:
    Apr 27, 2009
    Posts:
    423
    melscript:

    //Grab a list of everything selected.
    string $lsS[] = `ls -sl`;
    //Now create a loop to process the file export command.
    for ($i = 0; $i < `size ($lsS)`; $i ++)
    {

    //create the name to output.
    string $output = ("/data/" + $lsS($i) );
    //select the object and then export it
    select $i;
    file -op "" -typ "Fbx" -pr -es $output;
    }
     
  3. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    Exported files listed into the debug log :)

    Code (csharp):
    1.  
    2.  
    3. print ( SAMA_ExportListToSeparateFBX (`ls -sl -l`));
    4.  
    5.  
    6. global proc string [] SAMA_ExportListToSeparateFBX (string $objLs[])
    7. {
    8.     string $fileLs[];
    9.     int $i = 0;
    10.    
    11.     string $dir = `workspace -q -sn` + "/Exports/";
    12.  
    13.     if (!`filetest -d $dir`) sysFile -md ($dir);
    14.    
    15.     for ($obj in $objLs)
    16.     {
    17.         string $nameBuffer[] = stringToStringArray ($obj, "|");
    18.         $fileLs[$i] = $dir + $nameBuffer[`size $nameBuffer` -1];
    19.  
    20.         select -r $obj;
    21.         FBXExport -f $fileLs[$i] -s;
    22.        
    23.         $i ++;     
    24.     }
    25.  
    26.     return $fileLs;
    27. }
    28.  
     
  4. Yurgh

    Yurgh

    Joined:
    Feb 20, 2018
    Posts:
    1
    If you want a corrected version of the MEL script :

    //Grab a list of everything selected.
    string $lsS[] = `ls -sl`;
    //Now create a loop to process the file export command.
    for ($i = 0; $i < `size ($lsS)`; $i ++)
    {

    //create the name to output. Don't forget to modify the pathfile
    string $output = ("the path to your files" + $i + ".fbx" );
    //select the object and then export it
    select $lsS[$i];
    file -force -options "v=0;" -typ "FBX export" -pr -es $output;
    };
     
  5. unity_0xf2X2AixnXgeA

    unity_0xf2X2AixnXgeA

    Joined:
    May 22, 2018
    Posts:
    1
    The last one works great!
    Any idea how to export those elements with object/group name?

    And furthermore any chance to get a reverse script?
    Select folder -> Re-import all files from selected folder

    Regards,