Home Technical Talk

Multi export .obj in Maya 2012 ?

polycounter lvl 9
Offline / Send Message
jimpaw polycounter lvl 9
I need to find a way to export several objects in the same scene to seperate obj:s. Anyone know how to do that ? , I am using Maya 2012.

thanks !

Replies

  • Froyok
    Options
    Offline / Send Message
    Froyok greentooth
    Select your objects, run this script :
    // individually...
                string $objSel[] = `ls -sl`;
                string $objItem;
                string $objFolder = ""; //the path of the folder where you want to export
                
                sysFile -md $objFolder;
                
                select -cl;
    
                for ($objItem in $objSel) {
                    select -r $objItem;
                    string $objOutname = ($objFolder + "/" + $objItem + ".obj");
                    $objOutname = substituteAllString($objOutname, "|", "");
                
                    file -op "groups=0;ptgroups=0;materials=0;smoothing=0;normals=1" 
                        -f //force
                        -chn 1 //channels
                        -sh 0 //shaders
                        -exp 0 //expressions
                        -con 0 //constraint
                        -ch 0 //construction history
                        -typ "OBJexport" 
                        -pr //preserve reference
                        -es //export selected
                        $objOutname;
                        
                    print( "Exported : " + $objItem + ".obj");
                }
    
    Don't forget to put a foldername for the $objFolder variable, like :
    string $objFolder = "C:\\DESKTOP";
    



    You can find this function inside my maya tools script otherwise ! ;)
    www.froyok.fr/blog/2012-05-frotools-3-0-a-better-ui-for-a-better-workflow
  • David Wakelin
    Options
    Offline / Send Message
    1. Select ONLY the Chosen Object you want to export to an OBJ
    2. Go to File > Export Selection > Click on the small square box
    3. Select File type OBJ > Click Export Selection Button
    4. Choose File Location to save :)
  • David Wakelin
    Options
    Offline / Send Message
    Froyok's idea is quicker tho :P
  • jimpaw
    Options
    Offline / Send Message
    jimpaw polycounter lvl 9
    Froyok wrote: »
    Select your objects, run this script :
    // individually...
                string $objSel[] = `ls -sl`;
                string $objItem;
                string $objFolder = ""; //the path of the folder where you want to export
                
                sysFile -md $objFolder;
                
                select -cl;
    
                for ($objItem in $objSel) {
                    select -r $objItem;
                    string $objOutname = ($objFolder + "/" + $objItem + ".obj");
                    $objOutname = substituteAllString($objOutname, "|", "");
                
                    file -op "groups=0;ptgroups=0;materials=0;smoothing=0;normals=1" 
                        -f //force
                        -chn 1 //channels
                        -sh 0 //shaders
                        -exp 0 //expressions
                        -con 0 //constraint
                        -ch 0 //construction history
                        -typ "OBJexport" 
                        -pr //preserve reference
                        -es //export selected
                        $objOutname;
                        
                    print( "Exported : " + $objItem + ".obj");
                }
    
    Don't forget to put a foldername for the $objFolder variable, like :
    string $objFolder = "C:\\DESKTOP";
    

    You can find this function inside my maya tools script otherwise ! ;)
    www.froyok.fr/blog/2012-05-frotools-3-0-a-better-ui-for-a-better-workflow

    Thanks alot man that is fantastic !
  • jimpaw
    Options
    Offline / Send Message
    jimpaw polycounter lvl 9
    Froyok's idea is quicker tho :P

    The whole idea is to have a way to export many object at once ( each object get a seperate obj file ) anyway it says error getting shader and that it cant open obj even if i do it your way. That is really strange , the built in functions should work ?
  • jimpaw
    Options
    Offline / Send Message
    jimpaw polycounter lvl 9
    I cant get your script to work. it doesnt do anything what can i be doing wrong ? I have Maya 2012.



    Froyok wrote: »
    Select your objects, run this script :
    // individually...
                string $objSel[] = `ls -sl`;
                string $objItem;
                string $objFolder = ""; //the path of the folder where you want to export
                
                sysFile -md $objFolder;
                
                select -cl;
    
                for ($objItem in $objSel) {
                    select -r $objItem;
                    string $objOutname = ($objFolder + "/" + $objItem + ".obj");
                    $objOutname = substituteAllString($objOutname, "|", "");
                
                    file -op "groups=0;ptgroups=0;materials=0;smoothing=0;normals=1" 
                        -f //force
                        -chn 1 //channels
                        -sh 0 //shaders
                        -exp 0 //expressions
                        -con 0 //constraint
                        -ch 0 //construction history
                        -typ "OBJexport" 
                        -pr //preserve reference
                        -es //export selected
                        $objOutname;
                        
                    print( "Exported : " + $objItem + ".obj");
                }
    
    Don't forget to put a foldername for the $objFolder variable, like :
    string $objFolder = "C:\\DESKTOP";
    

    You can find this function inside my maya tools script otherwise ! ;)
    www.froyok.fr/blog/2012-05-frotools-3-0-a-better-ui-for-a-better-workflow
  • Froyok
    Options
    Offline / Send Message
    Froyok greentooth
    I just tested it again (since it's the same as the one inside my toolset) and it's working.

    Do you get any specific errors ?
Sign In or Register to comment.