скрипт создан для изменения значение скорости в Adobe after effects, но почему то при запуске ошибка \"Unable to execute at line 8. Execution halted\"
// Define the function to apply time stretch
function applyTimeStretch() {
// Get the currently selected layer in the active composition
var curComp = app.project.activeItem;
var curLayer = curComp.selectedLayers[0];
// Apply the Time Stretch effect to the selected layer
var timeStretchEffect = curLayer.Effects.addProperty(\"Time Stretch\");
// Set the Time Stretch effect\'s speed to 33.333%
timeStretchEffect.property(\"Speed\").setValue(33.333);
}
// Define the script author\'s name
var authorName = \"FRAIDEN\";
// Define the function to bind the key
function bindKey() {
// Create the script menu item
var menuCommandName = \"Apply Time Stretch\";
var menuCommandId = \"applyTimeStretchId\";
app.menuActions.add(menuCommandName, menuCommandId);
// Add the menu item to the Layer menu
var layerMenu = app.menuBar.menu(\"Layer\");
layerMenu.addMenuItem(menuCommandId, authorName + \" : \" + menuCommandName, \"\", true);
// Bind the key to the menu item
var keySequence = \"^T\"; // Ctrl + T
var keySequenceId = app.findKeyModifiers(keySequence) + app.charToKeyCode(keySequence.slice(-1));
app.addMenuItem(menuCommandId + \"Key\", \"Apply Time Stretch (Ctrl+T)\", keySequence, true);
app.addEventListener(\"onKeyDown\", function (event) {
if (event.keyName == keySequenceId.toString()) {
app.executeCommand(menuCommandId);
}
});
}
// Call the functions
applyTimeStretch();
bindKey();
// Define the function to apply time stretch
function applyTimeStretch() {
// Get the currently selected layer in the active composition
var curComp = app.project.activeItem;
var curLayer = curComp.selectedLayers[0];
// Apply the Time Stretch effect to the selected layer
var timeStretchEffect = curLayer.Effects.addProperty(\"Time Stretch\");
// Set the Time Stretch effect\'s speed to 33.333%
timeStretchEffect.property(\"Speed\").setValue(33.333);
}
// Define the script author\'s name
var authorName = \"FRAIDEN\";
// Define the function to bind the key
function bindKey() {
// Create the script menu item
var menuCommandName = \"Apply Time Stretch\";
var menuCommandId = \"applyTimeStretchId\";
app.menuActions.add(menuCommandName, menuCommandId);
// Add the menu item to the Layer menu
var layerMenu = app.menuBar.menu(\"Layer\");
layerMenu.addMenuItem(menuCommandId, authorName + \" : \" + menuCommandName, \"\", true);
// Bind the key to the menu item
var keySequence = \"^T\"; // Ctrl + T
var keySequenceId = app.findKeyModifiers(keySequence) + app.charToKeyCode(keySequence.slice(-1));
app.addMenuItem(menuCommandId + \"Key\", \"Apply Time Stretch (Ctrl+T)\", keySequence, true);
app.addEventListener(\"onKeyDown\", function (event) {
if (event.keyName == keySequenceId.toString()) {
app.executeCommand(menuCommandId);
}
});
}
// Call the functions
applyTimeStretch();
bindKey();
Ответ
0
(0 оценок)
0
function applyTimeStretch() {
// Get the currently selected layer in the active composition
var curComp = app.project.activeItem;
var curLayer = null;
if (curComp && curComp.selectedLayers.length > 0) {
curLayer = curComp.selectedLayers[0];
} else {
alert("Please select a layer before running this script.");
return;
}
// Apply the Time Stretch effect to the selected layer
var timeStretchEffect = curLayer.Effects.addProperty("Time Stretch");
// Set the Time Stretch effect's speed to 33.333%
timeStretchEffect.property("Speed").setValue(33.333);
}
попробуй так. надеюсь помогло