December 18th 2015 08:00:19am
Welcome to Free Function Friday episode 13 aeVer. Today we take getting the version number of After Effects to the next level. Why? Because getting the version number cleanly is not as simple as you might expect with ExtendScript.
Simply calling
app.version;
will give you the full version number of the After Effects application you are currently running. This will usually be a group of three numbers joined by a “.” and an “x”, like this “13.2×49”.
13.2×49 breaksdown into this…
As far as software versioning in general goes, the standard involves a Major, Minor, SubMinor(aka: Maintainence, or Patch), and a Build number. These numbers refer to various stages in the development process, and are used to keep track of every change made to a software. To understand more about software versioning formats you can read more at the software versioning wiki.
Now if you were trying to compare that value, to say, make sure a user was running After Effects CS6 or newer then you would need to do parsing to that “13.2×49” string just to get the 13 part so you could compare it to see if it was higher or lower than 11. Why 11? That would be CS6’s actual software version number. Confusing, I know. It would be a lot easier if you could just say something like
app.version.major
and just get “13”, and that is what we are doing today. The aeVer function will allow us to get the following values.
//example: 13.2×49
aeVer.major (returns 13)
aeVer.minor (returns 2)
aeVer.subMinor (returns null since it does not exist)
aeVer.build (returns 49)
aeVer.full (returns 13.2)
Much easier than parsing and re-assembling the info to get those values every time. Granted of course we will have to do those tasks for this function, but that is the great part about functions, they are valuable code that can be reused if built right. Just copy and paste it into your current script and you immediately have access to it without all the typing.
For our use we mostly only use three of the four number sets, and that is because it does not seem that After Effects has utilized the sub minor number yet, but it may show up in the future so we should be prepared for it. Adobe just released After Effects 13.6.1 bug fix yesterday.
As a side note, After Effects version numbers come in two forms. One is the actual software version number, and the other is the public name for the software like CS4 and CC 2015. Here is a list of the public names and numbers that each primary version started on. A full history can be viewed on the Wiki page.
General After Effects naming history:
Source Code:
alert(aeVer().build);
/* TESTING ABOVE */
function aeVer(){
var ae, aeFullVer, aeFullVerSplit, verSec, full, major, minor, subMinor, build;
var aeFullVer = app.version;
ae = aeFullVer.split("x");
verSec = ae[0].split(".");
major = verSec[0];
minor = subMinor = null;
(ae.length > 1) ? build = ae[1] : build = null;
switch(verSec.length){
case 1:/*Major only with forced 0 for Minor*/
full = major + ".0";
break;
case 2:/*Major & Minor only*/
minor = verSec[1];
full = (major + "." + minor);
break;
case 3:/*Major, Minor, & Maintainance*/
minor = verSec[1];
subMinor = verSec[2];
full = (major + "." + minor + "." + subMinor);
break;
}
return {
'raw': aeFullVer,
'major': major,
'minor': minor,
'subMinor': subMinor,
'build': build,
'full': full
};
}