// DialogSimpleButton.jsx
// how to add buttons in script, which on click run different codes?
// regards pixxxelschubser
function SimpleDialog() {
var w = new Window('dialog', 'Select Placement');
this.windowRef = w;
w.orientation = "column";
btn1 = w.add('button',undefined,'Top Left');
btn2 = w.add('button',undefined,'Top Right');
btn3 = w.add('button',undefined,'Bottom Left');
btn4 = w.add('button',undefined,'Bottom Right');
btnOK = w.add('button',undefined,'OK');
btnCancel = w.add('button',undefined,'Cancel');
btn1.onClick = function() {
/*JET_ReplaceWithSymbol.jsx
//A Javascript for Adobe Illustrator
//Purpose: Replaces selected items with Instances of a Symbol from the Symbols Panel.
//The desired Symbol can be defined by its index number (its number of occurrance in the Panel).
*/
var docRef=app.activeDocument;
//Uncomment next line and remove var symbolNum=6 to add prompt back in. - BSP
//var symbolNum=prompt("Enter the number of the Symbol you want to replace each selected object",6);
//Updated for stud count placement on 10/22/2020 at 2:19 p.m. - Aaron Thesing.
var symbolNum=12;
for(i=0;i<docRef.selection.length;i++){
var currObj=docRef.selection[i];
var currLeft=currObj.left;
var currTop=currObj.top;
var currWidth=currObj.width;
var currHeight=currObj.height;
var currInstance=docRef.symbolItems.add(docRef.symbols[symbolNum-1]);
//currInstance.width=currWidth //currInstance.height;
//currInstance.height=currHeight;
currInstance.left=currLeft;
currInstance.top=currTop;
currInstance.selected=true;
currObj.remove();
redraw();
}
};
btn2.onClick = function() {
/*
JET_ReplaceWithSymbol.jsx
A Javascript for Adobe Illustrator
Purpose: Replaces selected items with Instances of a Symbol from the Symbols Panel.
The desired Symbol can be defined by its index number (its number of occurrance in the Panel).
*/
var docRef=app.activeDocument;
//Uncomment next line and remove var symbolNum=6 to add prompt back in. - BSP
//var symbolNum=prompt("Enter the number of the Symbol you want to replace each selected object",6);
//Updated for stud count placement on 10/22/2020 at 2:19 p.m. - Aaron Thesing.
var symbolNum=12;
for(i=0;i<docRef.selection.length;i++){
var currObj=docRef.selection[i];
var currLeft=currObj.left;
var currTop=currObj.top;
var currWidth=currObj.width;
var currHeight=currObj.height;
var currInstance=docRef.symbolItems.add(docRef.symbols[symbolNum-1]);
//currInstance.width=currWidth //currInstance.height;
//currInstance.height=currHeight;
currInstance.left=(currLeft+currWidth)-currInstance.width;
currInstance.top=currTop;
currInstance.selected=true;
currObj.remove();
redraw();
}
};
btn3.onClick = function() {
/*
JET_ReplaceWithSymbol.jsx
A Javascript for Adobe Illustrator
Purpose: Replaces selected items with Instances of a Symbol from the Symbols Panel.
The desired Symbol can be defined by its index number (its number of occurrance in the Panel).
*/
var docRef=app.activeDocument;
//Uncomment next line and remove var symbolNum=6 to add prompt back in. - BSP
//var symbolNum=prompt("Enter the number of the Symbol you want to replace each selected object",6);
//Updated for stud count placement on 10/22/2020 at 2:19 p.m. - Aaron Thesing.
var symbolNum=12;
for(i=0;i<docRef.selection.length;i++){
var currObj=docRef.selection[i];
var currLeft=currObj.left;
var currTop=currObj.top;
var currWidth=currObj.width;
var currHeight=currObj.height;
var currInstance=docRef.symbolItems.add(docRef.symbols[symbolNum-1]);
//currInstance.width=currWidth //currInstance.height;
//currInstance.height=currHeight;
currInstance.left=currLeft;
currInstance.top=(currTop-currHeight)+currInstance.height;
currInstance.selected=true;
currObj.remove();
redraw();
}
};
btn4.onClick = function() {/*
JET_ReplaceWithSymbol.jsx
A Javascript for Adobe Illustrator
Purpose: Replaces selected items with Instances of a Symbol from the Symbols Panel.
The desired Symbol can be defined by its index number (its number of occurrance in the Panel).
*/
var docRef=app.activeDocument;
//Uncomment next line and remove var symbolNum=6 to add prompt back in. - BSP
//var symbolNum=prompt("Enter the number of the Symbol you want to replace each selected object",6);
//Updated for stud count placement on 10/22/2020 at 2:19 p.m. - Aaron Thesing.
var symbolNum=12;
for(i=0;i<docRef.selection.length;i++){
var currObj=docRef.selection[i];
var currLeft=currObj.left;
var currTop=currObj.top;
var currWidth=currObj.width;
var currHeight=currObj.height;
var currInstance=docRef.symbolItems.add(docRef.symbols[symbolNum-1]);
//currInstance.width=currWidth //currInstance.height;
//currInstance.height=currHeight;
currInstance.left=(currLeft+currWidth)-currInstance.width;
currInstance.top=(currTop-currHeight)+currInstance.height;
currInstance.selected=true;
currObj.remove();
redraw();
}
};
defaultElement = btnOK;
cancelElement = btnCancel;
btnOK.active = true;
btnOK.onClick = function() {
stuff = "Placing Order Number Now";
w.close();
}
w.show();
}
var stuff = null;
SimpleDialog ();
if (stuff) alert(stuff);