About
Changes the material color of selected layers to black. Useful for quickly resetting layer materials or creating high-contrast compositions.
Code
// Cavalry Script: Change Selected Layers to Black (Updated)// This script changes the material color of selected layers to black// Uses the working api.getSelection() methodconsole.info("Changing selected layers to black...");// Get selected layers using the working APIvar 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 layerfor (var i = 0; i < selectedLayers.length; i++) {var layerId = selectedLayers[i];var layerName = api.getNiceName(layerId);try {// Check if the layer has a material attributevar hasMaterial = api.hasAttribute(layerId, "material");if (hasMaterial) {// Set the material color to black using RGBA values (0,0,0,255)api.set(layerId, {"material.materialColor.r": 0, // Red: 0"material.materialColor.g": 0, // Green: 0"material.materialColor.b": 0, // Blue: 0"material.materialColor.a": 255 // Alpha: 255 (fully opaque)});console.log("✓ Changed material color to black for: " + layerName);processedCount++;} else {console.warn("⚠ Layer '" + layerName + "' doesn't have a material attribute");}