Tag Archive for: Notes

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!

Update [10 Feb 2020]: Made sure the import command explicitly points to the specified folder directory (Thanks Cody for pointing out that the script didn’t work for you!)

global proc rf_objSeqImport() {
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){
    print ("Importing " + $objFiles[$i] + "... \n");
    file -import -type "OBJ"  -ignoreVersion -ra true -mergeNamespacesOnClash false -namespace ("objImport" + $i) -options "mo=1"  -pr  -importTimeRange "combine" ($folder + $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++;
};
}
rf_objSeqImport();