
Code: Select all
myPanel.butTwo = myPanel.add("editText", [45, 10, 100, 30], "5");
The full script is here: (I used Lloyd Alvarez's duplicate layer script from the AENY video as a test and built the UI via Ian Haigh's Ease & Whiz script style cause it made more sense to me)
Code: Select all
function Dup_buildUI(thisObj) {
var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Duplicator", [100, 100, 300, 300]);
//Jeff Almasol's solution to fix text color
var winGfx = myPanel.graphics;
var darkColorBrush = winGfx.newPen(winGfx.BrushType.SOLID_COLOR, [0,0,0], 1);
//notes------------------------------------[10, 10, 40, 30] = [LeftEdge, TopEdge, ButtonEdge, ButonEdge]
//"Qty:" text
myPanel.butOne = myPanel.add("staticText", [10, 10, 40, 30], "Qty:");
//Input box
myPanel.butTwo = myPanel.add("editText", [45, 10, 100, 30], "5");
myPanel.butTwo.graphics.foregroundColor = darkColorBrush; //Keeps text black at all times
//"Do It!" button
myPanel.butThree = myPanel.add("button", [10, 40, 70, 60], "Dup It!");
myPanel.butThree.onClick = dupIt; //launch "dupIt" function when button is clicked
return myPanel;
}
function dupIt()
{
app.beginUndoGroup("Dup It!")
var myComp = app.project.activeItem;
if(myComp instanceof CompItem) {
//Selected layers loop
var myLayers = myComp.selectedLayers;
for (var i = 0; i < myLayers.length; i++) {
var myLayer = myLayers[i]
var selLayers = myLayer;
var numCopies = 10;
var counter = 0;
app.beginUndoGroup("Dup It!")
while(counter < numCopies){
selLayers.duplicate();
counter++
app.endUndoGroup()
}
}
}
}
Dup_buildUI(this);
Code: Select all
var numCopies = 10;