Free Function Friday Ep.23 – getCurComp

February 26th 2016 08:00:22am

Welcome to Free Function Friday episode on getting the current composition. The function this week is very simple and short. It just condenses a few lines into a single function for convenience.

When trying to check for the currently open comp in a project it can be simply called by typing

app.project.activeItem;

This would return the actively selected item in the project or the currently open composition depending on which panel is active. We will be adding an if statement to check and make sure it returns only CompItems, or null so we can verify the results. This will prevent any other item in the project, like a FolderItem or FootageItem from being returned by mistake.

Source Code:

function getCurComp(){
	var curComp = app.project.activeItem;
	if(curComp instanceof CompItem){
		return curComp;
	}else{
		return null;
	}
}
Checkout more:
Houdini Mardini Wind
Houdini Mardini River
After Effects ExtendScript Training: Ep. 4
Cinema4D Attach Splines To Animated Objects
Houdini Mardini Ancient