Hey there.
I’m aware that many artists don’t use OBJ sequences any more.
But now and then this may come in handy. Which happened to me.
And odd enough Maya doesn’t allow to import obj sequences. i used
it some years ago in max and it worked quite nicely.
So i took the time to write a python script for it. With a little help
from my Buddy John P. Neumann aka Arrantsquid here it is.
Hope it will help you. If not, you can still learn a bit from the code
Cheers
import maya.cmds as cmds
current_scene=cmds.ls(assemblies=True)
def selectDir():
basicFilter = "*.obj"
filename=cmds.fileDialog2(fileMode=4,ds=1, caption="Select Sequence",fileFilter=basicFilter)
uniToStr=str(filename)
global objList
filePath=uniToStr.split("'")
search=".obj"
objList=[mesh for mesh in filePath if search in mesh]
cmds.textScrollList(path, edit=True, append=objList)
def importer():
objList.sort()
for each in objList:
loaded=cmds.file(each,i=True,dns=True)
cmds.deleteUI('objwindow',window=True)
getMeshes()
def loadWin():
if cmds.window('objwindow',exists=True):
cmds.deleteUI('objwindow',window=True)
win=cmds.window('objwindow',title="Load Obj sequence",widthHeight=(250,450))
cmds.columnLayout()
cmds.text('Path to files')
global path
path=cmds.textScrollList(w=250)
browseButton=cmds.button(label='browse',w=250,c='selectDir()')
importButton=cmds.button(label='import',w=250,c='importer()')
cmds.showWindow(win)
def getMeshes():
newScene=cmds.ls(assemblies=True)
meshList=[mesh for mesh in newScene if mesh not in current_scene]
cmds.group(meshList,n="OBJ_GROUP")
for i in range(len(meshList)):
cmds.setKeyframe(meshList[i],attribute='visibility',value=0,t=0)
cmds.setKeyframe(meshList[i],attribute='visibility',value=1,t=i+1)
cmds.setKeyframe(meshList[i],attribute='visibility',value=0,t=i+2)
loadWin()

Your script works really well. Thanks!
I’m not sure exactly how to express it in Maya terms, but if you wanted to render the sequence, right now you would have to apply materials to every frame. It would be much more convenient to just set it once and have it applied everywhere.
Do you know how to do this?
Hi David thank you for your comments.
I can put a shader selector in it if you still need it.
thanks for that, i like *.obj and will test it asap
Just wanted to say thanks for this script! Very elegant.
Thank you sir. glad you enjoy it. any suggestions are welcome. cheers Ricardo
Hi Ricardo,
Thanks a lot for your script.
I needed an STL sequence importer so I used yours as a base and changed a couple lines. It is basically yours but with a few changes so the visibility animation works properly with STL files.
Still some cleanup to do but works.
Would you like it to be shared here?
Cheers
Hi Bill. Glad it helped. If you want to share be my guest. Thanks for the comments.
Hello. My obj sequence is accompanied by a texture *.jpg sequence (each obj has a corresponding unique jpg). How would I load these textures and apply them to obj’s using your script?
Thank you.
Hi Xzuma. Thank you for your comment.
Plz tell me what shader u are using and ill arrange the script for you.
Cheers
Ricardo
Hi mayapy! Let’s assume I will be using Lambert. One frame of my animation can be seeing here: http://dl.dropbox.com/u/18776108/eliotmerged.zip . it uses materials file, which references two jpg files included. The geometry has a glitch right now, but it should not matter for this script.
Very much obliged.
here it is.
It creates a Shader common to all geometry. Then you just have to go to the shader and insert the image sequence in the file node.(check image image sequence in parameters).
hope it helps
cheers
import maya.cmds as cmds current_scene=cmds.ls(assemblies=True) #shader creation - if u want can change from lambert to blinn or phong. shader=cmds.shadingNode("lambert",asShader=True,name='ObjectShader') #------------------------- ^ change above if desire ------------------------- file_node=cmds.shadingNode("file",asTexture=True) shading_group= cmds.sets(renderable=True,noSurfaceShader=True,empty=True) cmds.connectAttr('%s.outColor' %shader ,'%s.surfaceShader' %shading_group) cmds.connectAttr('%s.outColor' %file_node, '%s.color' %shader) #------------------------------------------------------------------------- def selectDir(): basicFilter = "*.obj" filename=cmds.fileDialog2(fileMode=4,ds=1, caption="Select Sequence",fileFilter=basicFilter) uniToStr=str(filename) global objList filePath=uniToStr.split("'") search=".obj" objList=[mesh for mesh in filePath if search in mesh] cmds.textScrollList(path, edit=True, append=objList) def importer(): objList.sort() for each in objList: loaded=cmds.file(each,i=True,dns=True) cmds.deleteUI('objwindow',window=True) getMeshes() def loadWin(): if cmds.window('objwindow',exists=True): cmds.deleteUI('objwindow',window=True) win=cmds.window('objwindow',title="Load Obj sequence",widthHeight=(250,450)) cmds.columnLayout() cmds.text('Path to files') global path path=cmds.textScrollList(w=250) browseButton=cmds.button(label='browse',w=250,c='selectDir()') importButton=cmds.button(label='import',w=250,c='importer()') cmds.showWindow(win) def getMeshes(): newScene=cmds.ls(assemblies=True) meshList=[mesh for mesh in newScene if mesh not in current_scene] cmds.group(meshList,n="OBJ_GROUP") for i in range(len(meshList)): cmds.sets(meshList[i],e=True,fe=shading_group) cmds.setKeyframe(meshList[i],attribute='visibility',value=0,t=0) cmds.setKeyframe(meshList[i],attribute='visibility',value=1,t=i+1) cmds.setKeyframe(meshList[i],attribute='visibility',value=0,t=i+2) loadWin()hi ,
i want to use ur script but iam getting this error :
// Error: current_scene=cmds.ls(assemblies=True)
//
// Error: Syntax error //
can u plz tel me what iam doing wrong
Hi Nitish.
do you have > import maya.cmds as cmds
in the beginning?
If not it will not work. you have to paste the whole code
into your script editor.
If you don’t import the maya cmds. cmds wont work. check also if you are in the mel tab instead of the python tab.
cheers
R.