AE to C4D

Moderator: Paul Tuersley

Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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

v1.4 UPDATE - JUL 10
Added CS5 compatibility.

v1.3 UPDATE - AUG 08
1. Now imports rotation for all layers, not just cameras.
2. Fixed bug when importing cameras with static rotation values.

Original After Effects composition:
Image

Resulting Cinema 4D project:
Image

Thanks to Paul Babb, Rick Barrett and Liam Stacy at Maxon, Ko Maruyama, Stu Maschwitz, Dale Bradshaw, Nab, Steve Kirby and Salvador Zalvidea for their help and ideas.

Instructions:
1. Put pt_AEtoC4D.jsx in Adobe After Effects / Scripts
2. Put pt_AEtoC4D.CSC in Cinema 4D / library / scripts.
3. Animate your scene in After Effects using a Camera with Layer > Transform > Auto-Orient set to Off. Animate rotation using the XYZ Rotation properties, not Orientation.
4. Select the cameras and layers you want to export and choose File > Scripts > pt_AEtoC4D.jsx. You'll be prompted to save a text file.
5. In C4D, select Plugins > User Scripts > pt_AEtoC4D and select that text file.

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.
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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.

Nimpsy posted a similar solution for moving tracking data:
http://maxon.digitalmedianet.com/articl ... p?id=42002
NOTE: It would be fairly simple for me to adapt the script to pass tracking data if anyone wants it?

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.
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

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.

The COFFEE language:
Apparently COFFEE's a bit like C++ (which I don't know) and Javascript (like AE scripting) but possibly more like C++. I can tell you one thing, it certainly seems a lot fussier that AE scripting for things like arrays, variable types and basic syntax. And I stayed well clear of classes.
Here are links to the COFFEE 9.5 SDK and the main forums I searched for answers:
http://www.maxon.net/pages/support/plug ... ads_e.html
http://www.plugincafe.com/forum/default.asp
http://www.c4dcafe.com/ipb/lofiversion/index.php/
http://forums.cgsociety.org/forumdisplay.php?f=182
http://www.3dattack.net/forum/index.php
http://xpresso24.com

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.

cheers,

Paul Tuersley
salvazalvi
Posts: 36
Joined: September 21st, 2004, 7:29 am

Hi Paul,

This is very good news. It will give us a lot more flexibility.
As soon as I'm back to my office I'll give your script a try with C4D 10.

It seems that the exact same reasons brought us to C4D.

I remember trying to do the same thing with 3DSMax and discovering that orientation and rotation don't do the same in AE. One entire project to trash.

Thank you very much.

Salvador
superblack
Posts: 1
Joined: February 28th, 2007, 4:29 pm
Location: Berlin | Germany
Contact:

Hi Paul,

Wow! That's really awesome that you actually made it happen. :-)

A big Thanks to you, and everyone who contributed to it. Really great giving this to the community...

All the best...

Sascha
C.Smith
Posts: 1
Joined: May 22nd, 2007, 10:56 am
Location: D-Ville
Contact:

Paul,

If the only reason you're using the camera rig is because of the rotation order problem, you can fix it pretty easily in C4D.

Instead of making just a camera and trying to make it do all the work, create 4 nested nulls with the camera as the last item in the chain.

-PositionNull (Dump the position keys on this from the array)
|-P Null data
_|-H Null data
__|-B Null Data
___|-Camera (all coords to zero, just link fov data to it)


The order of the nulls forces C4D to do the rotations in that order. I tried this on Yuppsters sample data and the cams locked right up.

This way your AE script can use the normal XYZ so people can use the cam as normal.
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

Thanks. Actually you can do it with just one null, the inverse of what the rig did in AE. The next version, which exports a normal AE camera, is nearly ready.

Paul
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

This is just a heads up to say check out the first post for an update to the script. This v1.1 update is really the first proper version of AEtoC4D, as it now exports normal After Effects cameras.
Humlan
Posts: 8
Joined: August 29th, 2004, 5:37 pm
Location: Sweden
Contact:

Great work Paul!

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.
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

It isn't possible with this script, and it sounds tricky to implement. For one thing, the script currently exports baked keyframe data from AE, so you can't really edit it once it's in C4D.
bfindleton
Posts: 1
Joined: December 28th, 2006, 11:44 am
Location: Pleasanton, CA
Contact:

Nice stuff, Paul. Looking forward to giving it a whirl.
Bruce Findleton
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

I just made a quick fix to ensure frame rate's of 29.97 round up to 30 in C4D (it was rounding to 29). So anyone using 29.97 or 23.976 should download it again.
Blabberlicious
Posts: 2
Joined: May 22nd, 2007, 12:34 am

Thanks for the time you put into this.

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.

Hope that make sense
pdeb
Posts: 21
Joined: November 7th, 2006, 2:07 pm

First off, thanks Paul for the great scripts for C4D, looks like you put your all into them.

I wanted to ask Blabberlicious if the scripts he uses to exchange AE and LW info are available somewhere.

thanks, pdeb
Benjibop13

Does this script work with After Effects CS3?
Last edited by Benjibop13 on May 13th, 2016, 4:21 am, edited 1 time in total.
Post Reply