Ronald Fong Obj Sequence to Maya MEL

Obj Sequence to Maya

A quick and dirty way to load an .obj sequence in Maya and have each geometry’s visibility automatically keyed to show up at the frame they are supposed to show up. Wrote this script as an experiment, but don’t have time to make a UI, so I just commented on the two variables to change accordingly to your setup. Cheers!

string $folder = "C:/objImport/"; //Change the folder directory to the folder containing your .obj sequence
string $mesh = "Mesh"; //Change the word 'Mesh' to the name of the geometry that would be imported

string $objFiles[] = `getFileList -folder $folder -filespec "*.obj"`;
int $i = 0;
while ((size($objFiles[$i])) > 0){
    file -import -type "OBJ"  -ignoreVersion -ra true -mergeNamespacesOnClash false -namespace ("objImport" + $i) -options "mo=1"  -pr  -importTimeRange "combine" $objFiles[$i];
    currentTime ($i+1) ; //visible on frame
    setAttr ("objImport" + $i + ":" + $mesh + ".visibility") 1;
    setKeyframe ("objImport" + $i + ":" + $mesh + ".v");
    
    currentTime $i ; //invisible before frame
    setAttr ("objImport" + $i + ":" + $mesh + ".visibility") 0;
    setKeyframe ("objImport" + $i + ":" + $mesh + ".v");
    
    currentTime ($i+2) ; //invisible after frame
    setAttr ("objImport" + $i + ":" + $mesh + ".visibility") 0; 
    setKeyframe ("objImport" + $i + ":" + $mesh + ".v");

    $i++;
};
0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *