redefinery

AE 7.0 Scripting Compatibility

This page describes changes in the After Effects 7.0 scripting interface that will affect compatibility of existing 6.0 and 6.5 scripts, and will require updates to your scripts for them to be compatible with 7.0. More topics will be added as I encounter issues running existing scripts in 7.0.

The following topics are covered:

Checking for the existence of a project

In After Effects 6.0 and 6.5, no project can be open. As a result, scripts that were aware of this situation would have checked if a project existed before trying to access project data, as follows:

// Detecting if a project is available
if (app.project != null)
{
    // project is available
}

However, in After Effects 7.0, a project is always available. Even if you close a project, a new one is automatically created for you. Closing the Project panel does not close the project as it does in 6.0 or 6.5. As such, the app.project test is not required, but it is safe to keep in your script, at the very least for future compatibility in case some future version of After Effects reverts this behavior.

Detecting a text layer

In After Effects 6.5, text layers are instances of the AVLayer object. Typically, code to determine if a layer was a text layer looked like the following:

// Detecting a text layer in AE 6.5:
if ((layer instanceof AVLayer) && (layer.property("sourceText") != null))
{
    // layer is a text layer
}

However, in After Effects 7.0, text layers are now represented as TextLayer objects, so the above code will fail. To ensure that your scripts works in 7.0, you can either do a version check for 7.0 and the appropriate check against TextLayer, or just detect for the sourceText property, as follows:

// Detecting a text layer in AE 6.5 and 7.0:
if (parseFloat(app.version) < 7.0)    // If earlier than 7.0
{
    if ((layer instanceof AVLayer) && (layer.property("sourceText") != null))
    {
        // layer is a text layer
    }
}
else                                  // If 7.0 or later
{
    if ((layer instanceof TextLayer) && (layer.property("sourceText") != null))
    {
        // layer is a text layer
    }
}

// ... or ...

if (layer.property("sourceText") != null)
{
    // layer is a text layer
}

This latter approach is less code and works in both 6.5 and 7.0, although it does not restrict other types of layers. However, it is debatable if other layers will gain a sourceText property in future versions of After Effects.

Detecting a camera or light layer

In After Effects 6.5, camera and light layers are instances of the Layer object. Typically, code to determine if a layer was a camera or light layer looked like the following:

// Detecting a camera layer in AE 6.5:
if ((layer instanceof Layer) && (layer.property("zoom") != null))
{
    // layer is a camera layer
}

// Detecting a light layer in AE 6.5:
if ((layer instanceof Layer) && (layer.property("intensity") != null))
{

    // layer is a light layer
}

However, in After Effects 7.0, camera layers are now represented as CameraLayer objects and light layers as LightLayer objects, so the above code will fail. To ensure that your scripts works in 7.0, you can either do a version check for 7.0 and the appropriate check against CameraLayer or LightLayer, or just detect for the zoom (for cameras) or intensity (for lights) property, as follows:

// Detecting a camera layer in AE 6.5 and 7.0:
if (parseFloat(app.version) < 7.0)    // If earlier than 7.0
{
    if ((layer instanceof Layer) && (layer.property("zoom") != null))
    {
        // layer is a camera layer
    }
}
else                                  // If 7.0 or later
{
    if ((layer instanceof CameraLayer) && (layer.property("zoom") != null))
    {
        // layer is a camera layer
    }
}

// ... or ...

if (layer.property("zoom") != null)
{
    // layer is a camera layer
}

// Detecting a light layer in AE 6.5 and 7.0:
if (parseFloat(app.version) < 7.0)    // If earlier than 7.0
{
    if ((layer instanceof Layer) && (layer.property("intensity") != null))
    {
        // layer is a light layer
    }
}
else                                  // If 7.0 or later
{
    if ((layer instanceof LightLayer) && (layer.property("intensity") != null))
    {
        // layer is a light layer
    }
}

// ... or ...

if (layer.property("intensity") != null)
{
    // layer is a light layer
}

This latter approaches are less code and work in both 6.5 and 7.0, although they does not restrict other types of layers. However, similar for text layers, it is debatable if other layers will gain a zoom or intensity property in future versions of After Effects.