Blender to After Effects

Hello, I’m working on a Different version of this script. my version export camera data in a .jsx script that should allow to avoid some .ma limits allowing a major interaction with AE. In future the use of .jsx should allow to export also lights and trackers (as empty layers) an yes also zoom data.

import Blender as B

#    Take the vals:
ObjSelect = B.Object.GetSelected()[0]

origName = ObjSelect.name

SC = B.Scene.GetCurrent()
SCR = SC.getRenderingContext()

width = SCR.sizeX
height = SCR.sizeY

AspectX = float(SCR.aspectRatioX())
AspectY = float(SCR.aspectRatioY())

pixelAspect = float(AspectX/AspectY)

FrameA = B.Get('curframe')
FrameP = B.Get('staframe')
FrameF = B.Get('endframe')

FrameRate = float(SCR.fps)
duration = float(FrameF/FrameRate)

FLenght = float(1/FrameRate)
AETime = float(0)


#    Initialazing Lists

LocX = []
LocY = []
LocZ = []
RotX = []
RotY = []
RotZ = []

#-----------------------------------------------------
#                    CREATING LISTS
#    Moves to the starting frame
B.Set('curframe', FrameP)

FrameA = FrameP
while FrameA < (FrameF + 1):
    B.Set('curframe', FrameA)
    
    #    Worldspace matrix
    mat= ObjSelect.mat
    
    LocX.append ((mat.translationPart().x)*100)
    LocY.append (-(mat.translationPart().z)*100)
    LocZ.append (-(mat.translationPart().y)*100)
    
    RotX.append (mat.toEuler().x)
    RotY.append (-mat.toEuler().z)
    RotZ.append (-mat.toEuler().y)
    
    FrameA += 1

#-------------------------------------------------------
    
#-------------------------------------------------------

#    File writing starts HERE!
File = open ('AEexporter.jsx','w')
#       this create the composition and setup its attributes
File.write ('var newComp = app.project.items.addComp("BlendComp", %i, %i, %f, %f, %i);
'
%(width, height, pixelAspect, duration, FrameRate))

File.write ('var newCamera = newComp.layers.addCamera("BlendCamera",[360.0,243.0]);

')

for i in range (FrameF-FrameP):
    File.write ('newCamera.property("position").setValueAtTime(%f, [%f, %f, %f]);
'
    %(AETime, LocX[i], LocY[i], LocZ[i]))
    File.write ('newCamera.property("rotationX").setValueAtTime(%f, %f);
'
        %(AETime, RotX[i]))
    File.write ('newCamera.property("rotationY").setValueAtTime(%f, %f);
'
        %(AETime, RotY[i]))
    File.write ('newCamera.property("rotationZ").setValueAtTime(%f, %f);
'
        %(AETime, RotZ[i]))
    AETime += (FLenght)


#    THE END -----------------------------------

B.Set('curframe', FrameP)
print "
Exporting Done!
Your file is located in \
Blender root folder, now send bug reports"

the real big trouble is that AEcamera use local rotation instead of blender camera which use global rotation and I don’t know how to translate it.
Beside you can’t have point of view data (that Blender doesn’t generate) but you have to disable it in AE (ctrl(cmd)+Alt+O on camera layer and then choose off).

Hope it can helps.

interesting can you explain this local rotation problem? don’t understand

Never thought about the jsx way!
Another hint on this matter :slight_smile:

Ok! Imagine we have a camera with 0° rotation data in both applications.

Now we rotate of 45° on X axis. Both application show in their X rotation a value of 45.

Again we rotate the cameras of -45°, but on Y axis. Here comes the troubles AE Camera show the “right” rotation, instead Blender’s camera show a strange amount of data!

If we continue, for example, rotating Z axis of -30° things don’t change.

Blender’s Rotation are more like a compass that point on a kind of “north pole”, instead AE rotation data record it’s “actual” inclination.

I hope now you understand what I mean :yes:

the real big trouble is that AEcamera use local rotation instead of blender camera which use global rotation and I don’t know how to translate it.
That is a real pain. If someone could figure out how to translate it it would be really really really great. I have a Autodesk-Flame Exporter thats works quite nice except for this rotation problem.

Beside you can’t have point of view data (that Blender doesn’t generate) but you have to disable it in AE (ctrl(cmd)+Alt+O on camera layer and then choose off).
You could animate your BlenderCam by tracking it to an empty. The coordinates of that empty would be the position of the AECamera’s point of interest. That should work i think.
Never heard of .jsx before, but that seems to be the way we could bring that exporter to life. thx a lot DhAoS

thanks, yeah I’ve noticed that too, specially when I was writing the script, silly :frowning:

This is a direct quote from “Creating Motion Graphics With After Effects” 3rd Edition, Version 6.5 by Trish & Chris Meyer…ch.19 Integrating With 3D Applications p.262 section: “Alias Maya”

"After Effects can import camera data as well as the position of any properly named nulls in a Maya project. Therefore a good working practice is to create a “locator” null that has either NULL or null in it’s name, place it exactly in the center of the object that will eventually receive your video (such as the face of our video wall here), and attach that object to your new null. Also make sure you create and animate a “rendering” camera in Maya, as After Effects ignores orthographic and perspective cameras.

I’m not sure what they mean by a “rendering” camera cuz I don’t use Maya but if anyone wants this info I will scan the pages of the book and e-mail it to you. The chapter contains info on exporting camera data from: Maya, 3ds Max, Electric Image Universe, Cinema 4D, LightWave, & Softimage|XSI. Some options may be more viable than others. Thanx for all the hard work guys!

Edit: Has anyone contacted Adobe directly concerning this? They are not ignorant of Blender! Ton, through the OpenExr board, has already suggested a convention for an interchangeable OpenExr format that would at least allow Blender multilayer files to be read by Photoshop. Perhaps Ton could throw a bit of his weight at Adobe if all else fails? He seems to be very good at getting his way. You can find those conversations here:

http://www.mail-archive.com/[email protected]/msg00437.html

Maya can render the viewport directly, without the need to add a camera, it’s irrelevant for us blenderheads, about asking for autodesk help… a company that only cares about windows and mac os, I don’t think thats a good idea

Not Autodesk, Adobe. Did you have a look at the link I posted?

Try to find versions of PS, Flash, Dream Weaver for linux? bah…

I’m well aware of that but what does it have to do with importing a Blender camera into AE? Blender runs on Windoze and Macs too you know. BTW, thanx for all your work on the builds!

I just don’t think they care about open source people like us, anyway lets stop this offtopic

Fine but are you interested in the info from the book?

Edit:

Forget I even asked you about the book. The question was really directed at DhAos anyway since this member seems to know a lot more about what’s actually going on in AE. I don’t understand hard headed attitudes like yours. Up until just now WE were not off topic. YOU were. If you hate the closed source giants so much then why the heck are you trying to Blindly write an exporter for one of their apps? That makes no sense what-so-ever. Sometimes the easiest route to a destination is the most direct one. With all the attention Blender is gathering these days it’s about to become impossible for even the giants to ignore. A great deal of Adobe users are Blender users also. I am one of them. Adobe just made the SINGLE LARGEST CONTRIBUTION TO MOZILLA since it’s inception! It seems to me that what you “think” may just be a bit off center from reality.

Adobe and Mozilla Foundation to Open Source Flash Player Scripting Engine

“Adobe’s work on the new virtual machine is the largest contribution to the Mozilla Foundation since its inception,” said Brendan Eich, chief technology officer, Mozilla Corporation, and creator of JavaScript. “Now web developers have a high-performance, open source virtual machine for building and deploying interactive applications across both Adobe Flash Player and the Firefox web browser. We’re excited about joining the Adobe and Mozilla communities to advance ECMAScript.”
http://www.mozilla.com/en-US/press/mozilla-2006-11-07.html

Adobe Opens Flash Scripting Engine Code

Adobe plans to open the source code for the scripting engine in the Flash Player, which will be incorporated into a new Mozilla open source project called Tamarin.
In a statement offered via e-mail, Satish Dharmaraj, CEO and co-founder of Zimbra, claims Adobe’s contribution to Tamarin will keep Firefox ahead of Internet Explorer. “According to our performance testing, Mozilla Firefox is already the fastest browser for rich, Ajax applications and this open source contribution will help Mozilla Firefox perform even faster for these rich applications.”
A Microsoft spokesperson was not immediately available for comment.
http://www.informationweek.com/industries/showArticle.jhtml?articleID=193600081

What is Adobe announcing?

Adobe is announcing its intention to release source code to Flex under an open source Mozilla Public License (MPL). This empowers both open source and commercial developers to extend and enhance the Flex framework to suit their own needs and to contribute to the evolution of the Flex framework.

http://labs.adobe.com/wiki/index.php/Flex_Open_Source_FAQ

@Rambobaby: I don’t think it’s a good idea to scan those pages here (it’s a bit illegal ;)) by the way if you find something that can be useful quote it.

To contact Adobe is a waste of time I suppose (indeed they don’t care about feature request (OTmode someone said node compositing? rotoscoping tool? :mad: \OTmode)) so I posted on AE developers forum.

By the way yesterday I searched on CGtalk forums and I find Many threads talking of similar topics. But when I came across such things like “Euler” “Quaternion” “4x4 matrix” soon I lost myself (I wasn’t good in mathematic :o). So if someone want to take a look…

RamboBaby for your information I tried contacting adobe since the beginning of this project with no response so don’t give me this attitude, I was just giving my opinion

I like to develop links to closed source applications just to make it easy for people to use blender instead of other aplications, good open source can deal with closed source aplications, thats mi opinion, thats why GIMP can open and write to PS files, it doesn’t mean that I like adobe

Yes, it does!

I’ve been also working on this over the past weeks and experienced the same trouble…
there is a very informative discussion about those issues with AE/C4D here :
http://www.aenhancers.com/viewtopic.php?t=653

but a bit too much math involved for me…

edit:
at the moment, I get pretty good matching camera moves when using the tracked-to empty positions from blender exported to AE camera’s point of interest… it seems to lock the rotation problem.
but then the apps camera lenses do not seem to match so well and perspective is not 100% the same…

Hello again,

I just found a set of scripts by Helge Mathee on mindthink.de that exports Softimage|XSI-data to AfterEffects.
Export XSI to xml: http://www.heulfritze.de/stuff/AE_Export3.js
Import xml into AE: http://www.heulfritze.de/stuff/xml_import.jsx
Example.xml: http://www.heulfritze.de/stuff/cameratest.xml
We have his permission to use his scripts to work on our blender-exporter.
We could translate the AE_Export3.js to Blender-python and use his xml-importer to load the data into AE or we merge the scripts and create a .jsx like DhAoS already did.
The Blender-cam has still to be animated by using an empty as point-of-interest (that’s my standard-procedure anyway).
I won’t have time to have a look at this for the next couple of months, but maybe one of you guys has.

rock’n’roll,
knekke

1234567890

Fortunately I got my wisdom-teeth pulled out today… :smiley:
So not much talking except for this:

So far PAL only and only one mesh for reference…
go to sleep now
cheers,
knekke

Thanks knekke, very usefull.
Maybe you find a way to export the lights too. :slight_smile: