AE to C4D

What type of scripts do you need?

Moderator: byronnash

Post Reply
salvazalvi
Posts: 36
Joined: September 21st, 2004, 7:29 am

Hi,

This is a copy of a mail I posted in the AE list :

I would like to know if someone here knew how to write a script doing that :

Take a layers 3D position data and format it this way :

Original :

Code: Select all

Adobe After Effects 7.0 Keyframe Data

    Units Per Second    25
    Source Width    768
    Source Height    576
    Source Pixel Aspect Ratio    1
    Comp Pixel Aspect Ratio    1

Transform    Position
    Frame    X pixels    Y pixels    Z pixels   
    0    394    298    -736.667    
    89    374    278    -756.667  


End of Keyframe Data 


Formated :

Code: Select all

Point    X    Y    Z
0    394    298    -736.667
1    374    -278    -756.667
I know this is quite easy to do with a simple text editor, but my main idea is to write an AE script that exports the following data to Cinema 4D :
Camera Position
Camera Point of interest
Layer position
Layer size
...

This would be great if a project started in AE required 3D elements and allow me to export the project to C4D.

If anyone has an idea how to do that or where to find help, I'll appreciate.

Thanks,

Salvador
Mylenium
Posts: 139
Joined: July 20th, 2005, 12:07 am

salvazalvi wrote: I know this is quite easy to do with a simple text editor, but my main idea is to write an AE script that exports the following data to Cinema 4D :
Camera Position
Camera Point of interest
Layer position
Layer size
How would you go about it? Do you plan on using a COFFEE expression in C4D to read your data? If not, your only option is XML import and for that:

a) Simple notation conversion wouldn't do it

b) You needed to add all the extra XML definitions

Especially the latter would make it a very large and slow script, even for just a simple camera animation. So from my point of view this really isn't feasible as a script until the day C4D has a simplified XML or ASCII importer or something like that.

Mylenium
[Pour Mylène, ange sur terre]
salvazalvi
Posts: 36
Joined: September 21st, 2004, 7:29 am

Yes, the idea is to write a coffee script in C4D.

But to be honest, so far, I've only used simple expressions in AE and simple Xpresso in C4D.

From AE to C4D by hand works quite well but it's not really fast : export data from AE, format it for C4D (this part involves a spreadsheet editor to invert Y axis), create a spline in C4D, import ASCII data to define the spline points, attach the camera's position, the camera's target or the layer's position to the spline, match C4D's amera with AE's.

So AE's script would only have to select relevant layers (based on layers name), copy relevant data, process and format it for C4D, create a txt file.

C4D's script would look into a folder containing relevant txt files, create each spline, camera, target,layer, light... with correctly set tag (attach to spline)

This doesn't seem impossible to do to me because I can understand needed steps, but maybe my lack of understanding of how both AE's scripts and C4D coffee work makes me believe it when in reality it isn't.

I know it's a long process, but hey, it's a good way to learn.

Salvador

P.S. : someone on AE's list posted me this link http://www.creativemac.com/articles/vie ... p?id=42002. It seems there already exists an Xpresso doing part of what I need.
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

salut Salvador,

I think I can help you ... if you post a typical txt file (recognized by c4d) containing all properties you want to export. What should be written to specify POI, orientation (instead of "Point") ...

As an example, select a 3D layer and apply the following script. Position datas will be exported in a txt file.
This can be easily extended to other properties and also easily modified if the format isn't exactly the one you need for C4D.

Code: Select all

{

var myComp = app.project.activeItem;
var myLayer = myComp.selectedLayers[0];
var myFileName = myComp.name + "_" + myLayer.name + "_position.txt";
var theFile = filePutDialog("Save and open layer's position :", myFileName, "TEXT txt");
if (theFile != null) {
	theFile.open("w","TEXT","????");
	theFile.write("Point	X	Y	Z\r");
	var nbFrames = Math.floor(myComp.duration / myComp.frameDuration);
	for (var f = 0; f < nbFrames; f++) {
		var myPos = myLayer.position.valueAtTime(f * myComp.frameDuration,true);
		theFile.write(f + "\t" + myPos[0] + "\t" + myPos[1] + "\t" + myPos[2] + "\r");
	}
	theFile.close();
	theFile.execute();
}

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

Hi nab (enfin salut),

Thanks,

With your script I managed to export both Position and POI with these little modifications (my first script editing !!!!) :

Code: Select all

{

var myComp = app.project.activeItem;
var myLayer = myComp.selectedLayers[0];
var myFileName = myComp.name + "_" + myLayer.name + "_position.txt";
var theFile = filePutDialog("Save and open layer's position :", myFileName, "TEXT txt");
if (theFile != null) {
   theFile.open("w","TEXT","????");
   theFile.write("Point   X   Y   Z\r");
   var nbFrames = Math.floor(myComp.duration / myComp.frameDuration);
   for (var f = 0; f < nbFrames; f++) {
      var myPos = myLayer.position.valueAtTime(f * myComp.frameDuration,true);
      theFile.write(f + "\t" + myPos[0] + "\t" + ("-") + myPos[1] + "\t" + myPos[2] + "\r");
   }
   theFile.close();
}

var myComp = app.project.activeItem;
var myLayer = myComp.selectedLayers[0];
var myFileName = myComp.name + "_" + myLayer.name + "_POI.txt";
var theFile = filePutDialog("Save and open layer's POI :", myFileName, "TEXT txt");
if (theFile != null) {
   theFile.open("w","TEXT","????");
   theFile.write("Point   X   Y   Z\r");
   var nbFrames = Math.floor(myComp.duration / myComp.frameDuration);
   for (var f = 0; f < nbFrames; f++) {
      var myPos = myLayer.pointOfInterest.valueAtTime(f * myComp.frameDuration,true);
      theFile.write(f + "\t" + myPos[0] + "\t" + ("-") + myPos[1] + "\t" + myPos[2] + "\r");
   }
   theFile.close();
}
}
It works quite well in C4D.

I'll ask C4D specialist of what exactly would be needed to have a layers orientation, lights parameters or camera settings and then I'll come back to you.

Thanks again,

Salvador

[EDIT : ] Do you know the difference between Orientation and Rotation in AE, manual isn't very explicit about it ?
So far I'm trying to export only the camera's position and POI because I can then use splines in C4D and attach the camera to these splines.
I've already had problems exporting AE rotation data to 3DSMax and the coders (who didn't spend much time but they where just giving me a hand) didn't manage to convert rotation data. But if I can have position and POI, I'll just need Z rotation to have everything I need.
This would mean that when animating a camera in AE script users would hve to always use these 3 parameters and not orientation or individual rotation values, unless we find a way to use them in C4D or convert them to POI values.
Last edited by salvazalvi on June 10th, 2006, 2:48 am, edited 1 time in total.
salvazalvi
Posts: 36
Joined: September 21st, 2004, 7:29 am

By the way, nab, do you mind if I share what's said here with members from AE list and FrenchC4D ? Of course I'll always mention who's done what.

Salvador
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

Of course, you can share info with other users.
Your first script is quite funny but bravo ! :D
When more details about the txt format will be given, I could write the script for you.
pixelrise
Posts: 5
Joined: February 2nd, 2007, 6:14 am

Hello to all.
It's great to be here.

I'm an AE and C4D user, but in expressions i'm a newbie with a few basic knowledge.
I always wonder how you can take the camera data from AE to C4D. It's very useful.
This expression looks great, but can someone write with details how you can achieve that in more depth?

Thanks in advance..
pixelrise
Posts: 5
Joined: February 2nd, 2007, 6:14 am

Is there anybody here who can help newbies?
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

What kind of help do your need ?
please be more precise
pixelrise
Posts: 5
Joined: February 2nd, 2007, 6:14 am

Thanx for your reply.
I would be more precise.

In that script you said that you can export camera data from AE to C4D. Where do you write that script? In the position of any 3D layer? I've done that and it says script error. I'm doing something wrong here?
And 2nd, if i can make to export that txt file which has my data, where do i have to go in C4D so i can use that script? How can i open it? How can i use it?

thanx in advance again and sorry for my english
nab
Posts: 203
Joined: November 29th, 2005, 3:00 am
Location: Royan
Contact:

This is a script (not an expression), so copy/paste the code into a text editor and save it with the .jsx extension.
In AE you access script through the command File>>Scripts>>...
pixelrise
Posts: 5
Joined: February 2nd, 2007, 6:14 am

Ooow...this is a script :?
I am irrelevant with this.

Anyway, i have execute the script to a 3D null layer and export me 2 txt files.
Congrats to me..:P
What is my next steps? How can i import that to C4D? That's the hard part..
Paul Tuersley
Posts: 704
Joined: June 5th, 2004, 7:59 am
Location: London, UK

I couldn't figure it out either. :)

Anyway, I hope you guys are still interested in this because I've been busy:
viewtopic.php?p=2430
Post Reply