A little while ago I stumbled into the necessity of transferring tracking data from Nuke to After Effects. Thanks to Dan Ebberts valuable advice, I came down to a working solution. I rewrite it into a post labelled well, so it is easier to find.
Nuke makes tracking data available through a plain ASCII .txt file, just a list of tuples. Each number has 4 decimal digits.
myFile = "absolute path to the file";
data = $.evalFile(myFile);
a = data.match(/[(backslash... I can't have it displayed)d.]+/g); //this RegEx reads every digit included into the string, it takes on each space and return as a separator, and creates an array
w = timeToFrames(time)*2; //or 3, if Z data are included
x = a[w];
y = thisComp.height-a[w+1]; //because Y coordinates in Nuke are flipped
z = a[w+2]; //only if Z data are included
[x,y,z]; //of course, pull the Z if unnecessary
First of all, I don't know why I'm not allowed to write the backslash (sorry about it), but it takes a backslash before the "d" in the regex.
Secondly, the absolute path must be written in the platform agnostic URI format, which looks like this: /C/MyPC/ProjectFolder/TrackingDataFile.txt
Thirdly, mind carefully to trim the composition to the length of the footage, because maybe you noticed that the code does not stop...
Fourthly, mind that the comp starts from frame 0! Otherwise, you can fix the code by adding the offset to the variable w.
Once you had the null working and sticking to its target, you can bake the animation by converting the expression to keyframe. This saves a lot of headaches.
I hope I didn't forget anything, and I hope y'all find this useful.