Reading in an OBJ sequence in Maya.. w/o importing

This will be a quick little update. Everyone knows each 3D package has their strengths and weaknesses. Like Maya is super flexible but horrible with simulations, and Houdini is amazing with simulations but you can pretty much forget about UV's and keyframe character animation of anything more than 2 bones. So artists end up transferring assets from one package to another one. For instance, sending an obj sequence from Houdini to Maya can become a horrendous task. Houdini reads and writes files without saving them in its own memory or scene files which boosts its performance. In the mean while Maya needs each obj file to be absorbed into its memory and scene file which can easily bump the size of a scene to GBs. Here is a little 2 liner for you to make Maya read those obj files per frame and not absorb them:

string $frame = ( "/path/to/the/obj/sequence/" + `currentTime -query` + ".obj" ); file -loadReference "sphereRN" -type "OBJ" -options "mo=0" $frame;

This assumes that the name of the Reference is sphereRN and the obj sequence is not padded with zeroes. Below is a sample, you will have to open the expression editor, find the expression and edit the path to your extracted folder.


This is long over due.

Turns out this method will fail when used with batch render as pointed out by Jacob Niedzwiecki.

Simply put, root of the problem is that the currentTime function cannot query the frame number during a batch or command line render. When set by the expression editor to be evaluated always, currentTime looks at the GUI time slider for input.

Thanks to Jacob for pointing this error out :) and also for finding a very elegant and simple solution for it as well. What I had in mind for a fix was overly complicated.

What follows is his solution to the problem. But first a little explanation on why this solution actually works.

Maya allows for scripts to run before render jobs, before frames, after frames, and after render jobs. These can be set at the Render Globals window. Parameter names are Pre render MEL, Pre render frame MEL, and so on. These parameters are MEL scripts that are set to run at specified times during a render or a batch render or a command line render.

When the same script is set to be evaluated always by the expression editor and also as a Pre render frame MEL script, it will update both the viewport and the renderer with the correct file name for the frame.

So to iterate again, the solution is to copy and paste the exact same script to Pre render frame MEL parameter in the Render Globals window.

Ping Graph in Maya

Here is a script I wrote that runs under Maya Python terminal. It checks the time the workstation spends to connect to about 20 webpages, and updates a bar graph that it creates real-time.

I implemented multi-threading to the script which Maya Python supports to a point. That point is using maya.cmds library which includes all the maya commands with transformations and such in threads.

So I had the Python script to do its trick with multi-threading, then stored the results to be executed thru MEL in strings. And piped those strings back into Maya's MEL commandPort via the Python telnet module.

Script is not fine tuned and it is not bug free, but it works. It also may only work on a Mac station since I used the ping command built into Mac OS X and there are slight differences between systems.


MEL2py conversion


I have been converting all the MEL procedures from the matrix assignment into Python. It needs a lot of debugging in the parts that create the shaders and groups, but the part that creates the geometry works.

Notice the different random patterns generated with the Python.random module compared to MEL random function.

Attaching archives during render time with -addsphereRI

This project was about creating and editing RenderMan attributes in Maya. preshapemel attribute was imported to the objects in the scene to switch the points of the actual object with a rib archive or a simple sphere before prman takes the scene over. The interface is created with the help of an rman script which does the heavy lifting of MEL UI programming.

First video on the right is the model without alterations, as seen in the Maya viewport. Second video is with the injected spheres, and the third one is with the custom rib archives.

xxxUI.rman script generates the xxxUI.mel script which is the graphical user interface for the newly created keyable parameters. xxxRI.mel is the actual script file that contains the backend of the replacement process. It calls the procedure in xxxUI.mel file to query the interface and pick up the values. Below are the complete scripts


I added a few more controls to the interface as well as centralizing them on a null (yes they are called nulls, not locators). New controls include the display of the original surface in the render, number of points to be used for injection, and some more experimental (read non-functioning) channels. The reason I wanted everything to be controlled from a null is because there may be more than one object in the scene where an artist might want to slap these injections on.

I have been experimenting with blobby surfaces as well as converting the vertices to particles so that they can generate curves, like a motion trail. This part of the code needs a lot of work, and I also have to find an elegant way to make the converted particles follow the vertices.

NOTE: If you need to delete the rman parameters from your scene and start over and don't have a clean scene file in hand, save your scene file as Maya ascii (it will hang maya for a while if you are on unix), search for all the lines that include "rman" and delete them. RenderMan UI is very buggy in terms of refreshing. Also if you used the script, there should be expressions attached to each shape node linking them to the control null, you will have to go thru each shape node and break the connections manually before removing the RenderMan attributes from the attribute editor. Otherwise you will encounter an epic bug that will force you use the ascii method.

It is like the Houdini copy node

The goal of this project was to create objects at the vertices of another object. The exact same function of the copy node of Houdini (a small fraction of it, of course). As usual with coding, there are many different approaches to this problem. A quick and dirty approach is to re-evaulate the object creation code each frame, deleting and re-creating the copied objects. A cleaner solution is to copy the objects and assign expressions to them making them follow the animated mesh. Of course if the mesh is high resolution, then there will be tons of objects copied on it, eventually crashing Maya. So the most elegant way to pull this off is to instance the objects instead of copying them, and attaching expressions to each instance.

Anyhow, I took the second route, and attached expressions to the copied objects.

First I tried to access each point by using something similar to[pointnum].px. It didn't work as I expected initially. px, py, pz information stored per point on the mesh all use each point's origin, so since there isn't a point to world space conversion taking place, everything pops to the world origin, unless there is some sort of offset that tells the points otherwise. Also the px, py, pz information isn't effected by skin clusters, or any sort of deformation. The only thing effecting them is assigning keyframes to each point seperately.

Then, I decided to use the pointPosition command. Using a clever loop, I was able to assign each object that is copied an expression that would transform its position based on a point on the mesh.

I am not putting excerpts from the script here since it would make no sense at all when it is in pieces. So download the whole script instead.