sidebar features
sidebar content

Go Back   Blender Artists Forums > General Forums > Python & Plugins

Reply
 
Thread Tools
osxrules's Avatar
osxrules osxrules is offline
Member
 
Join Date: Jun 2004
Location: Scotland
Posts: 3,944
Here is a script to export your camera from Blender into programs like Shake and After Effects for things like motion graphics:

http://www.geocities.com/ajr650/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.

EDIT: here is a movie showing what you can use it for

http://www.geocities.com/ajr650/test.mov

(try right-click download if it doesn't load)

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:

............................................
Pinky: Isn't life wonderful, Brain? Just think, we started out as lab mice forced to spend the whole day working our way through frustrating mazes that went absolutely nowhere. Now we get to do what humans do!

Last edited by osxrules; 22-Nov-07 at 16:49.
#1   Old 22-Nov-07, 16:27   
Reply With Quote


piotrekkosmala's Avatar
piotrekkosmala piotrekkosmala is offline
Member
 
Join Date: Nov 2007
Location: Warsaw . Poland
Posts: 14
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
#2   Old 22-Nov-07, 23:03   
Reply With Quote
osxrules's Avatar
osxrules osxrules is offline
Member
 
Join Date: Jun 2004
Location: Scotland
Posts: 3,944
Quote:
Originally Posted by piotrekkosmala View Post
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
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.
............................................
Pinky: Isn't life wonderful, Brain? Just think, we started out as lab mice forced to spend the whole day working our way through frustrating mazes that went absolutely nowhere. Now we get to do what humans do!
#3   Old 23-Nov-07, 00:13   
Reply With Quote
krupa krupa is offline
Member
 
Join Date: Aug 2004
Location: UK
Posts: 144
this looks great, cant wait to try, will have a go when back from this morning's meeting,

christian
#4   Old 23-Nov-07, 08:20   
Reply With Quote
piotrekkosmala's Avatar
piotrekkosmala piotrekkosmala is offline
Member
 
Join Date: Nov 2007
Location: Warsaw . Poland
Posts: 14
cool, i am waiting for this
#5   Old 23-Nov-07, 12:14   
Reply With Quote
osxrules's Avatar
osxrules osxrules is offline
Member
 
Join Date: Jun 2004
Location: Scotland
Posts: 3,944
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.



They're all the same size too, I'll see if I can get the tracking points to differ in size.
............................................
Pinky: Isn't life wonderful, Brain? Just think, we started out as lab mice forced to spend the whole day working our way through frustrating mazes that went absolutely nowhere. Now we get to do what humans do!
#6   Old 23-Nov-07, 13:12   
Reply With Quote
osxrules's Avatar
osxrules osxrules is offline
Member
 
Join Date: Jun 2004
Location: Scotland
Posts: 3,944
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:

............................................
Pinky: Isn't life wonderful, Brain? Just think, we started out as lab mice forced to spend the whole day working our way through frustrating mazes that went absolutely nowhere. Now we get to do what humans do!
#7   Old 23-Nov-07, 16:13   
Reply With Quote
dsp_418 dsp_418 is offline
Member
 
Join Date: Feb 2005
Posts: 178
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)
#8   Old 23-Nov-07, 17:32   
Reply With Quote
osxrules's Avatar
osxrules osxrules is offline
Member
 
Join Date: Jun 2004
Location: Scotland
Posts: 3,944
Quote:
Originally Posted by dsp_418 View Post
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.
............................................
Pinky: Isn't life wonderful, Brain? Just think, we started out as lab mice forced to spend the whole day working our way through frustrating mazes that went absolutely nowhere. Now we get to do what humans do!
#9   Old 23-Nov-07, 20:16   
Reply With Quote
osxrules's Avatar
osxrules osxrules is offline
Member
 
Join Date: Jun 2004
Location: Scotland
Posts: 3,944
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.
............................................
Pinky: Isn't life wonderful, Brain? Just think, we started out as lab mice forced to spend the whole day working our way through frustrating mazes that went absolutely nowhere. Now we get to do what humans do!
#10   Old 23-Nov-07, 20:46   
Reply With Quote
dsp_418 dsp_418 is offline
Member
 
Join Date: Feb 2005
Posts: 178
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.
#11   Old 29-Nov-07, 18:51   
Reply With Quote
dsp_418 dsp_418 is offline
Member
 
Join Date: Feb 2005
Posts: 178
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.
#12   Old 06-Jan-08, 12:39   
Reply With Quote
osxrules's Avatar
osxrules osxrules is offline
Member
 
Join Date: Jun 2004
Location: Scotland
Posts: 3,944
Quote:
Originally Posted by dsp_418 View Post
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!
I'm glad it's of use to you and thanks again for testing it.

Quote:
Originally Posted by dsp_418 View Post
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?
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.
............................................
Pinky: Isn't life wonderful, Brain? Just think, we started out as lab mice forced to spend the whole day working our way through frustrating mazes that went absolutely nowhere. Now we get to do what humans do!
#13   Old 07-Jan-08, 16:40   
Reply With Quote
Atom's Avatar
Atom Atom is offline
Member
 
Join Date: Jan 2006
Location: Ohio
Posts: 4,263
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.

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!
............................................
Intel DUO T9300 @ 2.5Ghz, Windows XP 64, 3Gb RAM, nVidia 9500M GS

Blender 2.49.2, Python 2.64

2.49b Python Scripts:
Blendgraph Meshfoot

2.49b Scenes:
After Effects Stroke
Sea Tubes

Page Rip or Tear
Opening A Book
Single Page Turn
Glow
Emulating 3DSMax Super Spray



#14   Old 07-Jan-08, 18:34   
Reply With Quote
dsp_418 dsp_418 is offline
Member
 
Join Date: Feb 2005
Posts: 178
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.
#15   Old 08-Jan-08, 00:12   
Reply With Quote
Atom's Avatar
Atom Atom is offline
Member
 
Join Date: Jan 2006
Location: Ohio
Posts: 4,263
dsp_418,

Thanks for the tip, I did not notice that the other objects were exported as well.
............................................
Intel DUO T9300 @ 2.5Ghz, Windows XP 64, 3Gb RAM, nVidia 9500M GS

Blender 2.49.2, Python 2.64

2.49b Python Scripts:
Blendgraph Meshfoot

2.49b Scenes:
After Effects Stroke
Sea Tubes

Page Rip or Tear
Opening A Book
Single Page Turn
Glow
Emulating 3DSMax Super Spray



#16   Old 08-Jan-08, 13:33   
Reply With Quote
meschoyez's Avatar
meschoyez meschoyez is offline
Member
 
Join Date: Dec 2006
Location: Córdoba, corazón de mi país ;) Argentina
Posts: 696
How i missed this thread!!!! I should've searched "Maya Ascii export" and not "Blender to AE"...
Quote:
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. Cool way to start the day!
............................................
lastt WIPs in here Puppet painters theatre, mainframe characters, apaches test, Oscar Chichoni's chimneys

finished artwork: Chromanorama & There! Our Home!

www.epanimation.com.ar | my studio
www.martineschoyez.com.ar | my personal site
#17   Old 11-Jan-08, 11:24   
Reply With Quote
heldrida's Avatar
heldrida heldrida is offline
Member
 
Join Date: Apr 2007
Posts: 184
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!
#18   Old 11-Jan-08, 22:05   
Reply With Quote
aku aku is offline
Member
 
Join Date: Jun 2005
Location: aku@méxico:~/tamaulipas/victoria/
Posts: 15
@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

By the way can you put the video on youtube? you webpage is suspended.
............................................
aku
mi pagina web Tutorial UVmap LSCM
hispanoparlante? esblender g-blender niel
#19   Old 12-Jan-08, 01:02   
Reply With Quote
kirpre's Avatar
kirpre kirpre is offline
Member
 
Join Date: Mar 2002
Location: Rochester, New York
Posts: 555
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.
............................................
kirpre

Last edited by kirpre; 12-Jan-08 at 13:25.
#20   Old 12-Jan-08, 13:11   
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 19:03.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Logo and website design copyright © 2006 by froodee design bureau. All rights reserved.
Other Blender Sites
new icon Blender Homepage »
The official Blender homepage
new icon BlenderNation »
Fresh Blender News, Every Day
new icon Blenderart Magazine »
Blender articles, tutorials and images.
Blender Headlines
Featured Artwork
Short animation: Barrel by Phlopper
Woolly mammoth by sebastian_k
Photorealistic classic furniture by eMirage
Social BlenderArtists