pt_AEtoC4D:
These scripts export data from After Effects to Cinema 4D. AEtoC4D exports AE cameras, nulls with the position and rotation of other layers, the comp frame rate, duration and start frame. Requires AE 7.0 and C4D R9.6, or greater.Download pt_AEtoC4D_v1.4.zip

NOTES:
1. This script doesn't export camera zoom. You'll have to set the camera's field of view manually in C4D after import. Check out the test project, which uses nulls as a guide to help line up the FOV.
2. This script doesn't export parented layers.

Last edited by Paul Tuersley on September 1st, 2007, 6:25 am, edited 5 times in total.

AEtoC4D R&D:
Here's the story of how I researched and developed these scripts. It gives me a chance to credit all the people who've helped in the making.

I switch between vfx and motion graphics freelance work and have mainly used AE my whole career. Increasingly with the motion graphics work I'm needing more basic 3D elements, such as a stock model or some 3D text. AE's 3D capabilities haven't changed all that much since their introduction in AE5, and while there are some excellent third party solutions, they have some limitations.

Regularly having to get someone else to knock out these 3D elements isn't good. Clearly, animators that know a little of a 3D app have an advantage, and around here that app seems to be C4D.

Learning 3D:
So a week ago I decided it was time to learn a bit of C4D. I spent about 3 days going through tutorials to get a basic overview of the app. I got thinking about how it wouldn't be much fun if I couldn't get AE's camera data over to C4D. I still want to animate the camera and do the bulk of my animation in After Effects, I just want to sync C4D up so the 3D renders will match into the AE scene. I reasoned that I'd be a lot more enthusiastic about learning C4D if I knew the solution existed, so I decided to do some research.

AEtoC4D research:
To start, there was the request from Salvazalvi and the subsequent export script written by Nab:viewtopic.php?t=456
It seems there is a solution for moving position data, but it's a bit fiddly on the C4D end (using ASCII data import) and it isn't working for rotation. So not quite there yet.

Googling on, Simon Wicker posted this solution for Maya cam to C4D:http://forums.cgsociety.org/showthread.php?t=253099
It uses C4D's Expresso (node based expressions) to convert the Maya camera data into suitable values for C4D. Very interesting stuff, but it still involves the ASCII data importer and some other fiddly steps.

Simon's solution was picked up by Yuppster, who tried to use it to translate AE camera data:http://forums.cgsociety.org/showthread. ... 7&t=321029
If you read the thread you'll see they also run into problems with rotation, caused by AE's rotation order being different to C4D's.

I decided to worry about rotation later. I wanted a more automatic solution than Expresso seemed to offer, something more like AE scripting, where it just reads the text file, sets things up and creates the keyframes. This meant learning C4D's scripting language, called COFFEE.

Last edited by Paul Tuersley on April 23rd, 2007, 2:28 pm, edited 1 time in total.

Many cups of COFFEE later:
I can't tell you how much pain I went through trying to write the COFFEE side of the script. It was a similar experience to when I started learning AE scripting and mainly for the same reason, a lack of available real world examples of COFFEE code. There is some stuff out there, but not much.

That's not the case with AE scripting anymore. Thanks to AEnhancers and a number of other sites, there's a lot of code out there, which is a great reference for usage examples when you hit something new. In C4D, it seems that you can keep your script as a regular COFFEE script (like mine, ending in .CSC) or turn it into a plugin (source = .COF, compiled = .COB). Unfortunately, most COFFEE scripters seem to favour the compiled .COB format, so there's no chance to study their code.

Problem - Recording Position keyframes:
The first major problem I had was simply finding a way to set the Position keyframes. I couldn't find a single usage example of someone using COFFEE to set a sequence of Position keyframes and from what I read, it seems C4D 9.5 COFFEE has some surprising limitations in this area.

I eventually found I could cheat by using CallCommand() which behaves similarly to AE scripting's app.executeCommand() for accessing menu commands. So my workaround for setting keyframes using COFFEE is basically to get the script to press the "Next Frame" button, then change the X, Y and Z values before hitting the "Big Red Record" button. It's dumb, but it works.

Problem - Doing the same for rotation:
I thought that'd be simple, but once I got the script to hit the "Goto Start Frame" button and repeated the process for the Rotation values, the keyframes came in ok, but now the "Big Red Record" button was also resetting the Position keys I'd already set. I eventually fixed it by storing the Position values in an array and applying the Position and Rotation keyframes at the same time.

Problem - Rotation order:
It was finally time to investigate the rotation order issue. I remembered Stu Maschwitz had posted a solution to AE's "wrong" rotation order on creative-workflow-hacks.com for Dale Bradshaw's auto camera rig creation script:http://www.creative-workflow-hacks.com/ ... r-effects/
It was my lucky day. Stu's AE camera rig uses the same rotation order as C4D!!!! So that's why, for the time being, this script requires you to use that camera rig. I'm fairly sure I know enough now to create an inverse rig in C4D instead, but once you've used the rig, you may find you prefer it. If you pan then tilt AE's normal camera, you'll find the view is no longer level with the horizon. That doesn't happen with the camera rig or in C4D.

What's next?
So here I am, a week later, with what will hopefully prove to be a useful script. Depending on the demand, there are a lot of improvements that should be possible. Automatically setting the duration and frame rate in C4D, exporting other things like nulls, lights and layers (as reference planes). If someone can help me with the math, I can probably sort out zoom / field of view too.

One possible snag is I've heard the animation system has been overhauled in C4D R10. So it's quite possible this script won't work in it. There's no SDK available for COFFEE in R10 yet either so I have no idea what's changed.

Well that's it, if you've made it to the end, thanks for taking the time. And if you try the script, let me know how it works out for you.

A question; would it be possible to update an existing animation instead of creating a brand new scene?
What I really want is a seamless way to go back-and-forth between After Effects and C4D, tweaking the animations on either end and have the changes updated in the other.

I go from Lightwave to AE via a set of scripts.
One very crucial factors in managing this well is to have a mean to adjust the scale of the 2D/3D environments.
In Lightwave if you model at a real worlds scale, the camera data come into AE fine, but the scale is so small that the 3D AE space is hard to work in.
The scripts I us let you up scale the export to AE, rather than modify the actual scale of the models - which is a no-no, in most cases.
I've just made the switch to C4D, but it struck me that it might be a important factor - including a simple multiplier to 'attenuate' the scale during export from AE to C4D.