• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

[Branched] How to combine different scripts?

Engaged ,
Nov 03, 2020 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

171

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
community guidelines
Adobe
Community Expert ,
Nov 03, 2020 Nov 03, 2020

Copy link to clipboard

Copied

LATEST

Hi @BryanPagenkopf 

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

Votes

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
community guidelines