Maya Ascii camera export script

Here is a script to export your camera from Blender into programs like Shake and After Effects for things like motion graphics:

http://dev-art.co.uk/files/tracking.py.zip

If you unzip it and drop it into your scripts folder and update menus, it should show up under the scripts > export menu. It doesn’t for me unfortunately but I think my update menus function is broken.

If you can’t get it to appear like me, open it in the text editor panel in Blender and hit alt-p.

When you run the script, it should open a save dialog and you just type in the name of your file and choose where to put it. It will then start the export.

It only exports the current camera because if you have a lot of cameras in a scene, they will all be loaded into your compositor which can get a bit cluttered and you can sometimes forget which camera you rendered with.

I haven’t tested this much with AE as I don’t use it so feedback about that would be good.

Instructions for using it with Shake: you make a Multiplane node and load the file in the camera section. Attach inputs as you see fit - for rendered inputs, lock the layer to the camera; for other inputs, make sure to reset them if needed or they will be positioned relative to the current camera position when attached to the Multiplane node.

In After Effects, I think you just import the .ma file and the camera loads into the scene. If someone can provide full instructions for AE, it would be appreciated. I might make a small tutorial up to show what it can be used for and it would be better to have instructions for AE users.

There is a known problem: because it uses tk for the native file dialog, the Mac menu bar will be replaced. Not sure how to prevent that happening I’m afraid so it means you lose your zoom function.

If anyone finds the script useful and wants to use it elsewhere, feel free to do so without crediting me. For example, if you have an exporter, it saves export time if you do the camera evaluation at the same time as your scene, especially if you have a lot of rigged meshes so just drop the code in place and it will export the .ma file along with your other data.

Any suggestions for improvements are very much welcome.

The graph paper is rendered and the Blender logo is added in Shake and they match up. You can use it for say adding sky images after rendering so you can adjust them in real-time without rendering your 3D models again.

Here’s a screen shot from Shake:

http://img122.imageshack.us/img122/8738/shakevp3.jpg

hello

first of all thanks for your work, i think this script is a milestone for motion designers
i try to test it with after effects and i think it works fine but i dont have a orientation in scene, tell me one thing - is it possible to export a blender’s empty object as after effects null objects? it will be cool for orientation and object placement

greets

Peter

I think so, I was meaning to do this before releasing it. I’d use a point cloud but I need to figure out how to get a point cloud in maya and then into the .ma file so I can see the format. Once I do that, it should be easy enough to add arbitrary object locations. I had an idea about using just empties though and you could put these on a separate layer to keep them separate from the scene.

this looks great, cant wait to try, will have a go when back from this morning’s meeting,

christian

cool, i am waiting for this :slight_smile:

Ok here is an update:

http://www.geocities.com/ajr650/tracking2.py.zip

It will now export all object center locations as tracking points along with empties and other cameras. Composite objects can be attached to these tracking points.

From what I can see, Shake only supports translation for the tracking points not rotation. If AE supports tracking point rotation, I will leave it in but I think it would speed up parsing if I remove the unneeded data.

I chose not to animate object centers for the time being because the file size goes up way too high and it takes forever for the compositor to parse the file so only empties and other cameras are animated.

I will check out ways to optimize the data so that static items are not exported per frame and then I may be able to include object animation. The export now uses objects in the visible layer so if you want to choose what items to export for tracking, put those into a layer and only turn that layer on.

Here is a screenshot of the scene with main camera + tracking points. There are about 5 cameras in that scene but they also show up as tracking points to avoid confusion about what camera is the main one.

http://img519.imageshack.us/img519/1760/trackingvo4.jpg

They’re all the same size too, I’ll see if I can get the tracking points to differ in size.

Another update:

http://www.geocities.com/ajr650/tracking3.py.zip

It seems After Effects needs the .ma file formatted differently and Shake works just the same with the changes so now you should see the same thing in AE:

http://img409.imageshack.us/img409/1756/trackingaegh7.jpg

Something weird here… the pal format is not kept when I import the .ma file in AE CS3
A part of this, the 3D objects added in AE seem they don’t good mix the 3D coordinates of the .ma scene (i.e. a simple 3D text layer added in AE looks like is moving around the scene while it should remain still)

Thanks for the feedback. AE does work quite differently from Shake and it expects more information. It also doesn’t seem to support the .ma format particularly well. It’s not reading the fps values properly - it only seems to read film (24fps), PAL(25fps) and NTSC(30fps) even though it supports more formats.

This should fix the frame size:

http://www.geocities.com/ajr650/tracking4.py.zip

but stick to 24,25 or 30 fps in Blender.

It might be best to avoid using Blender’s resolution presets as they don’t seem to match AE’s. For example, the PAL button in Blender gives you 720x576 with an aspect ratio of 54/51 (1.058) = 762 x 576. AE’s PAL is 720 x 576 with an aspect of 1.07 = 768 x 576. When I’m using rendering programs, I tend to just stick to an aspect of 1 and then render at the right resolution. So for widescreen pal, I’d go with 1024x576 with aspect of 1.

I’ll check what’s up with the tracking, I noticed that AE seems to be reading in a strange focal length value.

Ok so that last script seems to work for me in AE. I increased the scale on the tracking shapes so they are a bit easier to see.

Quick AE tutorial:
What I did was set Blender to 1024 x 576 aspect 100 x 100. Then used the script to save a .ma file.
In AE, file menu > import > file and choose the .ma file
This loads a folder of tracking points called Solids and now a single composition element with the name of the .ma file.
Double-click the composition element and it should load all the tracking points into the scene. You can use the manipulation controls in the top left - orbit camera tool etc (hotkey is c) - to move the 3D view.
Use the view menu > look at all layers if you get lost with some crazy camera movement. I wish the compositors had turntable view like Blender.
Now you can add other layers so maybe load in an image then drag it down to the composition.
Right-click the added image and make it a 3D layer.
Reset the position to 0 0 0.
If the Blender camera was looking at 0,0,0 you should see the image in view.
I had to scale the image down to about 0.5%.
The image should stay where it is while the camera moves around it.

To attach a composite object to a tracking point, you can simply parent it to one of the tracking shapes, then just reset the composite object position again if you want it to be in the same place.

Thanks osxrules!
I’ve seen your replies only now, I’ll check the updated script asap!
this is a top issue to me, it would be great get the proper workflow from blender to ae!!!

Thanks.

I’ve played with your script: actually, it rocks.
I’m not getting any kind of problem, and finally I can exchange data between Blender and After Effects. That’s really important for my job (and I think for many other people around who use Blender and do compositing in a commercial environment).
Thanks for your work!

One only little thing: every time I’ve to fix is the scale proportions (as already mentioned by you).
Do you think that could be possible to get a workaround for this?

Anyway, great job.

I’m glad it’s of use to you and thanks again for testing it.

I think it’s just a scene scale issue. Shake seems to load items in at the right size but AE is off by about a factor of 200 (hence the 0.5% scale - it could be a meters vs centimeters thing). If I scale items up for AE, they are too small in Shake. Shake has a scene scale parameter to correct it but there is another setting AE needs that messes up Shake’s device aspect ratio setting so I’ve separated them:

http://www.geocities.com/ajr650/tracking_ae.zip
http://www.geocities.com/ajr650/tracking_shake.zip

I might end up putting an interface on the script to allow people to set the scene scale and tracking point scale among other things on export and that way I could have one script for both apps but always having to click an interface for a few items that likely won’t be changed often doesn’t seem necessary ATM.

Very Good!

I tested tracking_ae using blender 2.45 with a trackTo constraint on the camera. The empty was located at 0,0,0.
I moved the camera around the default cube, creating keyframes as I go, and rendered out a movie.
I launched After Effects 7.0 and imported the MA file generated by the tracking_ae script.
I imported the blender generated movie of the camera panning the cube into After Effects.
I dropped the movie into the After Effects timeline.
Because I knew the default cube was located at 0,0,0 I created a text layer in After Effects, turned into a 3D layer and positioned it at 0,0,0.
The alignment is good.:RocknRoll:

While this was not conducted as a “pixel perfect” test, it certainly looks like a good match to me.
My next test would be to animate the empty the camera is tracking to and see if the tracking holds up to that test.

Thanks for the script!

A big thanks!
It works like a charm.
This script rocks, indeed. The gap is only a old memory now.

@ Atom: I can confirm, animating the empty works, no prob. here.
About the way to pass the position of the objects between Blender and AE the easiest way is simply create the empty object where you want to add your 3d layers in AE. Since this great script export the objects those are on the Blender scene, after imported the .ma, you’ve simply to copy the position property of your empty layer and paste it into the position property of your 3d layer. That’s it.

Thanks again for the great-great job.

dsp_418,

Thanks for the tip, I did not notice that the other objects were exported as well.

How i missed this thread!!! I should’ve searched “Maya Ascii export” and not “Blender to AE”…

That’s really important for my job (and I think for many other people around who use Blender and do compositing in a commercial environment).

Really.
Thanks a lot for the script. :smiley: Cool way to start the day!

Hi OsxRules!
I Would like to thank your time and knowledge, thanks a lot for sharing this with the community! I really appreciate your efforts in creating this!

Thanks a lot for your time and dedication!

@osxrules : Same as above.

Working just fine out of the box.

This is something i was waiting for a long time. Once again tanks a lot :yes:

By the way can you put the video on youtube? you webpage is suspended. :smiley:

Running the script I get an error saying that I don’t have the Tkinter module. What do I need to get this installed? Where can I find it? Thanks. I am running Pyhton 2.4.

edit: Forget it, I just needed to install Python 2.5.