Highlighted

[Branched] How to combine different scripts?

Participant ,
Nov 03, 2020

Copy link to clipboard

Copied

// 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);
 

[ branched from Script to place the File Name within the Art  to Illustrator  forum ]

[ title changed by moderator ]


TOPICS
Scripting

Views

40

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

[Branched] How to combine different scripts?

Participant ,
Nov 03, 2020

Copy link to clipboard

Copied

// 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);
 

[ branched from Script to place the File Name within the Art  to Illustrator  forum ]

[ title changed by moderator ]


TOPICS
Scripting

Views

41

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 03, 2020 1
Most Valuable Participant ,
Nov 03, 2020

Copy link to clipboard

Copied

Hi @BryanPagenkopf 

it seems you want to implement James E.Talmage script JET_ReplaceWithSymbol.jsx into that script: DialogSimpleButton.jsx – right?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Nov 03, 2020 0
Resources