Color
Script
Free

Change To White

By Jack Vaughan
Updated 11/1/2025

About

Changes the material color of selected layers to white. Useful for quickly resetting layer materials or creating high-contrast compositions.

Code

// Cavalry Script: Change Selected Layers to White (Updated)
// This script changes the material color of selected layers to white
// Uses the working api.getSelection() method
console.info("Changing selected layers to white...");
// Get selected layers using the working API
var selectedLayers = api.getSelection();
if (selectedLayers.length === 0) {
console.warn("No layers are selected. Please select some layers first.");
} else {
console.info("Processing " + selectedLayers.length + " selected layer(s)...");
var processedCount = 0;
// Loop through each selected layer
for (var i = 0; i < selectedLayers.length; i++) {
var layerId = selectedLayers[i];
var layerName = api.getNiceName(layerId);
try {
// Check if the layer has a material attribute
var hasMaterial = api.hasAttribute(layerId, "material");
if (hasMaterial) {
// Set the material color to white using RGBA values (255,255,255,255)
api.set(layerId, {
"material.materialColor.r": 255, // Red: 255
"material.materialColor.g": 255, // Green: 255
"material.materialColor.b": 255, // Blue: 255
"material.materialColor.a": 255 // Alpha: 255 (fully opaque)
});
console.log("✓ Changed material color to white for: " + layerName);
processedCount++;
} else {
console.warn("⚠ Layer '" + layerName + "' doesn't have a material attribute");
}