New in Beta: Material Assignment Scripting API
Hello AE scripters!
Version 27.1x52 of After Effects (Beta) introduces support for Material Scripting APIs.
You can now assign materials to 3D layers in the Advanced 3D renderer through scripting, enabling automated workflows where materials need to change on demand, like creating variations of a product ad that show different versions of the product.
Getting Started
Update to the latest After Effects (Beta) from your Creative Cloud app. Use the new API to assign Substance 3D materials or layer-based materials to a 3D model, parametric mesh, 3D text or shape layer.
Full documentation updates are available here, but here’s some highlights to get you started.
-
Access Material Assignments on a layer with
materialAssignment.property(string | index)
-
Set material overrides and sources with
setMaterialOverride(materialSource)
-
Check if a layer is used as a materialSource with
isMaterialSource
Scripting Example
// Create 3D type in the open comp and
// add materials to the front and side.
var comp = app.project.activeItem;
if (comp instanceof CompItem) {
// Set renderer to Advanced 3D
comp.renderer = "ADBE Calder";
// Add Text layer
var my3dText = comp.layers.addText("Cool 3D Type!");
// Make it 3D!
my3dText.threeDLayer = true;
my3dText.geometryOption.extrusionDepth.setValue(100);
my3dText.geometryOption.bevelStyle.setValue(2);
my3dText.geometryOption.bevelDepth.setValue(5);
// Set the Front face to an imported Subsar material from the project
var mySbsar = app.project.item(1);
var frontFace = my3dText.materialAssignment.property(MaterialAssignment.FRONT);
frontFace.setMaterialOverride(mySbsar);
// Enable the rest of the overrides
my3dText.addAllMaterialOverrides();
// Make a solid layer with 4 Color Gradient
var mySolid = comp.layers.addSolid([1,1,1], "Curl Noise", comp.width, comp.height, 1);
mySolid.property("ADBE Effect Parade").addProperty("ADBE 4ColorGradient");
mySolid.moveToEnd();
// Set the Side face to the solid layer in this comp
var sideFace = my3dText.materialAssignment.property(MaterialAssignment.SIDE);
sideFace.setMaterialOverride(mySolid);
//Enable Randomize Offset on the Side face
sideFace.randomizeOffset.setValue(true);
}
Notes and tips for the Material Assignment API
-
Features are only available while using the Advanced 3D renderer.
-
The Front, bevel, Side, and Back assignments of 3D Text and Shape layers may be selected with the following enumerated values:
-
MaterialAssignment.FRONT -
MaterialAssignment.BEVEL -
MaterialAssignment.SIDE -
MaterialAssignment.BACK
-
-
3D Model assignments can only be accessed by index or display name. For example a model with “Screen” as its third material may be accessed by either:
-
materialAssignment.property("Screen") -
materialAssignment.property(3)
-
-
The default material can be set on an assignment by passing null to
setMaterialAssignment(), but to fully remove the override, useremoveMaterialAssignment().
Please give this new scripting functionality a try and let us know how it's working for you.

