Skip to content

Instantly share code, notes, and snippets.

@karlrolson
Last active July 15, 2019 19:15
Show Gist options
  • Save karlrolson/1e70cfd12cd521e5a6e097512b728ca4 to your computer and use it in GitHub Desktop.
Save karlrolson/1e70cfd12cd521e5a6e097512b728ca4 to your computer and use it in GitHub Desktop.
This script clears caption text from multiple captions across multiple panels in Storyboard Pro
/*
-------------------------------------------------------------------------------
Name: TB_Delete_Caption_Text.js
Description: This script clears caption text from multiple captions across multiple panels.
Usage:
Author: Karl Olson & Corey Barnes
Created: 2018/8/26
Modified: 2018/8/30
Version: v.1.1
Notes: Should be functionally the same as version 1.0, just with better structure and naming.
-------------------------------------------------------------------------------
*/
function DeleteCaptions() {
MessageLog.trace("Delete Captions--------- ");
var selectionManager = new SelectionManager;
var captionManager = new CaptionManager;
var currentPanelSelection = selectionManager.getPanelSelection();
if (currentPanelSelection.length <= 0) return;
// Create a list of all caption box names.
var captionNames = new Array(0);
var numberOfCaptions = captionManager.numberOfPanelCaptions();
for (var j = 0; j < numberOfCaptions; ++j) {
var captionName = captionManager.nameOfPanelCaption(j);
if (captionNames.indexOf(captionName) == -1)
captionNames.push(captionName);
}
// Create a dialog displaying all caption names as checkboxes.
captionSelectionDialog = new Dialog;
captionSelectionDialog.title = "Delete Captions Named...";
var group = new GroupBox;
group.title = "Caption Names";
var checkBoxesArray = new Array(0);
for (var i = 0; i < captionNames.length; ++i) {
var aCheckBox = new CheckBox;
aCheckBox.text = captionNames[i];
checkBoxesArray.push(aCheckBox);
group.add(aCheckBox);
}
captionSelectionDialog.add(group);
var rc = captionSelectionDialog.exec();
// If dialog cancelled, return
if (!rc) {
return;
}
// Retrieve the selected caption names group.
var patterns = new Array(0);
for (var i = 0; i < checkBoxesArray.length; ++i) {
if (checkBoxesArray[i].checked == true) {
patterns.push(checkBoxesArray[i].text);
}
}
// Delete the caption text.
scene.beginUndoRedoAccum("Delete Captions");
for (var i = 0; i < currentPanelSelection.length; i++) {
for (var j = 0; j < patterns.length; j++) {
captionManager.setPanelCaptionText(patterns[j], currentPanelSelection[i], "");
}
}
scene.endUndoRedoAccum();
// Prepare report.
var finalMessage = "Captions cleared. :\n";
MessageBox.information(finalMessage);
}
@karlrolson
Copy link
Author

Gonna post a new revision with hopefully easier to understand names and structure after this note.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment