1
+ //Import Boujou 2d tracks to AE
2
+ //CC-BY Nik Ska, 2014
3
+
4
+ var parseBoujou = this ;
5
+
6
+ parseBoujou . go = function ( ) {
7
+
8
+ function createNull ( comp , _name ) {
9
+ var newTrackNull = comp . layers . addNull ( ) ;
10
+ newTrackNull . name = "Boujou Null_" + _name ;
11
+ newTrackNull . threeDLayer = true ;
12
+ newTrackNull . label = 10 ;
13
+ return newTrackNull ;
14
+ }
15
+
16
+ var textFile = File . openDialog ( "Choose a tracking data file" , "*.txt" ) ;
17
+
18
+ if ( textFile != null ) {
19
+ var textLines = [ ] ;
20
+ textFile . open ( "r" ) ;
21
+
22
+ while ( ! textFile . eof ) {
23
+ //reading file into lines
24
+ textLines . push ( textFile . readln ( ) ) ;
25
+ }
26
+
27
+ var activeComp = app . project . activeItem ;
28
+ if ( activeComp && activeComp instanceof CompItem ) {
29
+ app . beginUndoGroup ( "Parse Boujou" ) ;
30
+
31
+ //regex to match X/Y and null name
32
+ var XYmatch = / ( \d + ( [ \. ] \d + ) ? ) / g;
33
+ var nameMatch = / a u t o _ ( \d + ) / ;
34
+
35
+ for ( var t = 1 ; t < textLines . length ; t ++ ) {
36
+ if ( t > 5 ) {
37
+ var parsed = textLines [ t ] . match ( XYmatch ) ;
38
+ var nullNum = textLines [ t ] . match ( nameMatch ) [ 1 ] ;
39
+ //check for existing null
40
+ var curNull = activeComp . layer ( "Boujou Null_" + nullNum ) ;
41
+ //create one if there is no null
42
+ if ( ! curNull ) curNull = createNull ( activeComp , nullNum ) ;
43
+
44
+ if ( parsed ) {
45
+ // $.writeln(textLines[t].match(XYmatch))
46
+ // $.writeln(Number(parsed[2]), ", ", Number(parsed[3]));;
47
+
48
+ curNull . property ( "ADBE Transform Group" ) . property ( "ADBE Position" ) . setValueAtTime ( Number ( parsed [ 1 ] - 1 ) * activeComp . frameDuration , [ Number ( parsed [ 2 ] ) , Number ( parsed [ 3 ] ) , 0 ] ) ;
49
+ }
50
+ }
51
+ }
52
+
53
+
54
+ }
55
+
56
+ app . endUndoGroup ( ) ;
57
+ }
58
+ }
59
+
60
+ parseBoujou . go ( ) ;
0 commit comments