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

Custom Window Choices

New Here ,
Mar 11, 2019 Mar 11, 2019

I'm making a proof creator that will make a different window for each format of proof. So the initial Window opens a dropbox with the options RFID, Shrink, Label, and Flexo and I to open another window depending on which option I choose. From what I have made it will open all of the different window but not one specific. There is too much code specifying each window to create an if statement it seems, unless I'm doing this wrong. any help or advice would be appreciated.

TOPICS
Scripting
647
Translate
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

correct answers 1 Correct answer

Advocate , Mar 12, 2019 Mar 12, 2019

Salut !

var positionDefaut = 0, choise = "", cancelAction = false;

var popUp = new Window ('dialog', "what's the press type?");

        var btns = popUp.add('group');

    var PressType= popUp.add('dropdownlist', undefined,["Shrink", "Flexo","Label","RFID"]);

        PressType.selection = positionDefaut;

        popUp.alignChildren = 'left';

        popUp.spacing = 2;

    var btns = popUp.add('group');

    var helpGroup = popUp.add('group');

        btns.alignChildren = 'center';

        btns.margins = [0,1

...
Translate
Adobe
Community Expert ,
Mar 11, 2019 Mar 11, 2019

ScriptUI can be verbose, can you post your code to see if we can spot a way to make it more efficient?

Translate
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
New Here ,
Mar 11, 2019 Mar 11, 2019

var docRef = app.open( File  ('~/Desktop/ABHP.ait'));  
var wndNames = ['Wind1','Wind2','Wind3','Wind4','Wind5','Wind6','Wind7','Wind8'];
var layNames = ['W1','W2','W3','W4','W5','W6', 'W7','W8'];
var win =null;
  var popUp = new Window ('dialog', "what's the press type?");
        var btns = popUp.add('group'); 
    var PressType= popUp.add('dropdownlist', undefined,["Shrink", "Flexo","Label","RFID"]);
    popUp.alignChildren = 'left'; 
    popUp.spacing = 2; 
    var btns = popUp.add('group'); 
    var helpGroup = popUp.add('group');
    btns.alignChildren = 'center'; 
    btns.margins = [0,10,0,0]; 
    var ok = btns.add('button',undefined,"OK"); 
    var cancel = btns.add('button',undefined,"Cancel");
ok.onClick = function(){  
    if(PressType.input="Shrink"){
       (win = new Window ('dialog',"Enter Slit Width in mm!"))
        el.onClick = function(){ 
       win.close(); 
   }
}
}
popUp.show();
win = new Window('dialog', "Enter Slit Width in mm!")
    win.alignChildren = 'left'; 
    win.spacing = 2; 
    var chk = win.add('checkbox',undefined,"include artboard sized path");
    var helpGroup = win.add('group');
    var helpText = helpGroup.add('statictext', undefined, "Slit Width: Max. 450 mm, Min. 45 mm");
   
var DLC = docRef.swatches;
var dieColor = DLC.getByName('dieline').color;
var printArea = DLC.getByName('printArea').color;
var folds = DLC.getByName('Art Guides').color;
var White = DLC.getByName('White').color;
var Black = DLC.getByName('Black').color;
var Can = DLC.getByName('Can').color;
var Zero = DLC.getByName('Zero').color;
var Center = DLC.getByName('Center').color;
var botDot = 100;
var sideDot = 100;
var vDot = 100;
var toothSize = 88;
var xc = 1;

//LAYERS
var PrintArea = docRef.layers.add();
PrintArea.name = 'Print Area';
var WTLayer = docRef.layers.add();
WTLayer .name = 'White Print';
var dimL = docRef.layers.add();
dimL.name = 'Dimensions';
var DL = docRef.layers.add();
DL.name = 'Guides';
myJust = Justification.CENTER;
// CURRENT DATE
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
var hr = today.getHours();

if(dd<10) {
    dd='0'+dd
}
if(mm<10) {
    mm='0'+mm
}
today = mm+'.'+dd+'.'+yyyy + '.' + hr;

//  INPUT WINDOW
    var sz = win.add('group'); 
    sz.alignChildren = 'left';
    // Size
    var wid = sz.add('statictext',undefined,"Slit Width in mm"); 
    var slitWidth = sz.add('edittext',undefined,"228"); 
    slitWidth.characters = 8; 
    slitWidth.active = true;
    var height = sz.add('statictext',undefined,"Cut Height in mm"); 
    var cutHeight = sz.add('edittext',undefined,"123.825"); 
    cutHeight.characters = 8; 
    var layFlatWidth = (slitWidth.text - 4) / 2;
    var XX = sz.add('statictext',undefined, "Intials");
        XX = sz.add('edittext',undefined, "");
        XX.characters = 3;
    // only posting first 86 lines. its like 670 lines and I'm not sure if Im actually allowed to post the whole thing.

just looking advice how to make the variables of win dependent on the input of PopUp.

Translate
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
New Here ,
Mar 11, 2019 Mar 11, 2019

So far I have tried If-else statements to change what win is and if it matches it would be able to return the differences in variables in the new window but that doesn't seem to work, just makes two windows.

Translate
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
New Here ,
Mar 11, 2019 Mar 11, 2019

if (win = new Window('dialog', "Enter Slit Width in mm!")){

^^^ is what is supposed to be there instead of just declaring win as a new window, Ive been diddling around and I forgot to copy the original before I had changed a lot of it.

Translate
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
Contributor ,
Mar 12, 2019 Mar 12, 2019

Here is some idea which might help.
Create a function, which will show the popUp, and then make it return the selected value.
Basing on the value create else if statement or switch case.

function selectPressType() {

  var pressWindow = new Window("dialog", "Choose press type", undefined, {borderless: true});

  var selected = "";

  var r = new RegExp("&");

  var radioPanel = pressWindow.add("panel", undefined, "Choose press type");

  radioPanel.alignment = "center";

  radioPanel.alignChildren = "left";

  radioPanel.add("staticText", undefined, "");

  radioPanel.add("radiobutton", undefined, "&Shrink");

  radioPanel.add("radiobutton", undefined, "&Flexo");

  radioPanel.add("radiobutton", undefined, "&Label");

  radioPanel.add("radiobutton", undefined, "&RFID");

  var buttonGroup = pressWindow.add("group")

  buttonGroup.add("button", undefined, "Ok");

  pressWindow.show();

  for (var i = 0; i < radioPanel.children.length; i++) {

    if (radioPanel.children.value === true)

      selected = radioPanel.children.text;

    }

  if (selected != "")

    return selected.split(r)[1];

  else

    return radioPanel.children[1].text

}

var typeOfPress = selectPressType();

$.writeln(typeOfPress);

Above you can see an example with radiobuttons. If you need more explanation, or any help with adjusting it I'll try to help

You can ignore & sign, and Regexp - those are added to work with shortcuts.

Translate
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
Advocate ,
Mar 12, 2019 Mar 12, 2019

Salut !

var positionDefaut = 0, choise = "", cancelAction = false;

var popUp = new Window ('dialog', "what's the press type?");

        var btns = popUp.add('group');

    var PressType= popUp.add('dropdownlist', undefined,["Shrink", "Flexo","Label","RFID"]);

        PressType.selection = positionDefaut;

        popUp.alignChildren = 'left';

        popUp.spacing = 2;

    var btns = popUp.add('group');

    var helpGroup = popUp.add('group');

        btns.alignChildren = 'center';

        btns.margins = [0,10,0,0];

    var ok = btns.add('button',undefined,"OK");

    var cancel = btns.add('button',undefined,"Cancel");

        cancel.onClick = function() {cancelAction = true; win.close();}

        ok.onClick = function(){

          choise = PressType.selection.text;

          win.close();

        }

      popUp.show();

      if (!cancelAction) alert ("Votre choix est "+choise);

    //--------------

    win = new Window('dialog', "Enter Slit Width in mm!")

    win.alignChildren = 'left';

   

        XX = sz.add('edittext',undefined, "");

        XX.characters = 3;

  //------------------------

    if (choise == "Shrink") {win.show();}

De LR

Translate
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
New Here ,
Mar 13, 2019 Mar 13, 2019
LATEST

The dimensions of my finished product is super messed up now. Im not sure what I did to cause this, or what I can do to fix it.

var positionDefaut = 0, choise = "", cancelAction = false; 
   var docRef = app.open( File  ('~/Desktop/ABHP.ait'));  
var wndNames = ['Wind1','Wind2','Wind3','Wind4','Wind5','Wind6','Wind7','Wind8'];
var layNames = ['W1','W2','W3','W4','W5','W6', 'W7','W8'];
var popUp = new Window ('dialog', "what's the press type?"); 
        var btns = popUp.add('group'); 
    var PressType= popUp.add('dropdownlist', undefined,["Shrink", "Flexo","Label","RFID"]); 
        PressType.selection = positionDefaut; 
        popUp.alignChildren = 'left'; 
        popUp.spacing = 2; 
    var btns = popUp.add('group'); 
    var helpGroup = popUp.add('group'); 
        btns.alignChildren = 'center'; 
        btns.margins = [0,10,0,0]; 
    var ok = btns.add('button',undefined,"OK"); 
    var cancel = btns.add('button',undefined,"Cancel"); 
        cancel.onClick = function() {cancelAction = true; win.close();} 
        ok.onClick = function(){ 
          choise = PressType.selection.text; 
          win.close(); 
        } 
      popUp.show(); 
      if (!cancelAction) alert ("Votre choix est "+choise); 
    //-------------- 
    win = new Window('dialog', "Enter Slit Width in mm!") 
    win.alignChildren = 'left'; 
    var chk = win.add('checkbox',undefined,"include artboard sized path");
    var helpGroup = win.add('group');
    var helpText = helpGroup.add('statictext', undefined, "Slit Width: Max. 450 mm, Min. 45 mm");
   
var DLC = docRef.swatches;
var dieColor = DLC.getByName('dieline').color;
var printArea = DLC.getByName('printArea').color;
var folds = DLC.getByName('Art Guides').color;
var White = DLC.getByName('White').color;
var Black = DLC.getByName('Black').color;
var Can = DLC.getByName('Can').color;
var Zero = DLC.getByName('Zero').color;
var Center = DLC.getByName('Center').color;
var botDot = 100;
var sideDot = 100;
var vDot = 100;
var toothSize = 88;
var xc = 1;

//LAYERS
var PrintArea = docRef.layers.add();
PrintArea.name = 'Print Area';
var WTLayer = docRef.layers.add();
WTLayer .name = 'White Print';
var dimL = docRef.layers.add();
dimL.name = 'Dimensions';
var DL = docRef.layers.add();
DL.name = 'Guides';
myJust = Justification.CENTER;
// CURRENT DATE
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
var hr = today.getHours();

if(dd<10) {
    dd='0'+dd
}
if(mm<10) {
    mm='0'+mm
}
today = mm+'.'+dd+'.'+yyyy + '.' + hr;

//  INPUT WINDOW
    var sz = win.add('group'); 
    sz.alignChildren = 'left';
    // Size
    var wid = sz.add('statictext',undefined,"Slit Width in mm"); 
    var slitWidth = sz.add('edittext',undefined,"228"); 
    slitWidth.characters = 8; 
    slitWidth.active = true;
    var height = sz.add('statictext',undefined,"Cut Height in mm"); 
    var cutHeight = sz.add('edittext',undefined,"123.825"); 
    cutHeight.characters = 8; 
    var layFlatWidth = (slitWidth.text - 4) / 2;
    var XX = sz.add('statictext',undefined, "Intials");
        XX = sz.add('edittext',undefined, "");
        XX.characters = 3;
   
    var repeat = cutHeight;  
    var LF = win.add('group');
    var layflat = LF.add('statictext', undefined, "Postition of Fold from the left in mm");
    var LFdistance = LF.add('edittext',undefined,"50");
    LFdistance.characters = 8;
         
    var coInfo = win.add('group');
    var co = coInfo.add('statictext', undefined, "Company");
    var coName = coInfo.add('edittext',undefined,"");
    coName.characters = 30;
    var pInfo = win.add('group');
    var pNum = pInfo.add('statictext', undefined, "Part Number");
    pNum = pInfo.add('edittext', undefined, "");
    pNum.characters = 30;

    var P = win.add('group');
    P.alignChildren ="right";
    var pressType = P.add('statictext', undefined, "Press Type");
    var press = P.add('dropdownlist', undefined,["HP Digital", "Flexo"]);
    press.selection = 0;

    var C = win.add('group');
    C.alignChildren ="right";
    var color = C.add('statictext', undefined, "White");
    var C4 = C.add('dropdownlist', undefined,["No White", "White", "White x2", "White x4"]);
    C4.selection = 0;
    C4.characters = 5;
    var wP = C.add('dropdownlist', undefined,["Full White Ink", "Spot White Ink", "No White Ink"]);
    wP.selection = 0;
    wP.characters = 5;
   
    var SpotC = win.add('group');
    var spot2 = SpotC.add('edittext', undefined,"");
    spot2.characters = 12;
    var spot3 = SpotC.add('edittext', undefined,"");
    spot3.characters = 12;
    var spot4 = SpotC.add('edittext', undefined,"");
    spot4.characters = 12;
   
    var MT = win.add('group');
    MT.alignChildren ="right";
    var material = MT.add('statictext', undefined, "Material");
    var MType = MT.add('dropdownlist', undefined,["2183 Clear PVC", "2184 Clear PETG", "2188 Clear OPS"]);
    MType.selection = 0;
      
    var AD = win.add('group');
    AD.alignChildren ="right";
    var adhesive = AD.add('statictext', undefined, "Slip Coat");
    var ADType = AD.add('dropdownlist', undefined,["Clear Slip Coat", "Varnish Slip Coat", "White Slip Coat", "Clear Slip and Silver Foil"]);
    ADType.selection = 0;
    var whitePrintStatement = dimL.textFrames.add();

var ddl = win.add ("dropdownlist", undefined, [wndNames[0],wndNames[1],wndNames[2],wndNames[3],wndNames[4],wndNames[5],wndNames[6],wndNames[7]]); 
    ddl.selection = null;
   
    var fin = win.add('group');     
    fin.alignChildren ="right";
    var finish = fin.add('statictext', undefined, "Top Coat");
    var fType = fin.add('dropdownlist', undefined,["No Varnish", "Matte Varnish"]);
    fType.selection = 0;

    var core = win.add('group');
    core.alignChildren ="right";
    var coreSz = core.add('statictext', undefined, "Finish");
    var coreSize = core.add('dropdownlist', undefined, ["6\" Core",  "5\" Core",  "10\" Core", "3\" Core", "Sheeted"]);
    coreSize.selection = 0;
    var stK = core.add('dropdownlist', undefined, ["Rolls of", "Stacks of"]);
    stK.selection = 0;   
    var QTY = core.add('statictext', undefined, "Quantity");
    var QT = core.add('edittext', undefined,"");
    QT.characters = 5;

    var wind = win.add('group');
    wind.alignChildren ="right";
    var windD = wind.add('statictext', undefined, "Wind Direction");
    var WD = wind.add('dropdownlist', undefined,["Seam Out, Bottom First", "Seam Out Top First",
    "Seam In Bottom First", "Seam In Top First", "Sheeted", "Hand Sheeted", "Blank"]);
    WD.selection = 0;

    var btns = win.add('group'); 
    btns.alignChildren = 'center'; 
    btns.margins = [0,10,0,0]; 
    var okShrink = btns.add('button',undefined,"OK"); 
    var cancel = btns.add('button',undefined,"Cancel");
    cancel.onClick = function(){ 
        win.close(); 
    } 

   var win2 = new Window ('dialog',"Enter Label Size."); 
    win2.alignChildren = 'left'; 
    win2.spacing = 2; 
    var chk = win2.add('checkbox',undefined,"include artboard sized path");
    var helpGroup = win2.add('group');

var DLC = docRef.swatches;
var dieColor = DLC.getByName('dieline').color;
var printArea = DLC.getByName('printArea').color;
var folds = DLC.getByName('Art Guides').color;
var White = DLC.getByName('White').color;
var Black = DLC.getByName('Black').color;
var Can = DLC.getByName('Can').color;
var Zero = DLC.getByName('Zero').color;
var Center = DLC.getByName('Center').color;
var botDot = 100;
var sideDot = 100;
var vDot = 100;
var toothSize = 88;
var xc = 1;

//LAYERS
var PrintArea = docRef.layers.add();
PrintArea.name = 'Print Area';
var WTLayer = docRef.layers.add();
WTLayer .name = 'White Print';
var dimL = docRef.layers.add();
dimL.name = 'Dimensions';
var DL = docRef.layers.add();
DL.name = 'Guides';
myJust = Justification.CENTER;

// CURRENT DATE
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth()+1; //January is 0!
var yyyy = today.getFullYear();
var hr = today.getHours();

if(dd<10) {
    dd='0'+dd
}
if(mm<10) {
    mm='0'+mm
}
today = mm+'.'+dd+'.'+yyyy;

//  INPUT WINDOW 2
    var sz = win2.add('group'); 
    sz.alignChildren = 'left';
    // Size
    var wid = sz.add('statictext',undefined,"Label Width"); 
    var labelWidth = sz.add('edittext',undefined,"4.0"); 
    labelWidth.characters = 8; 
    labelWidth.active = true;
    var height = sz.add('statictext',undefined,"Label Height"); 
    var cutHeight = sz.add('edittext',undefined,"2"); 
    cutHeight.characters = 8; 
    var layFlatWidth = (labelWidth.text - 4) / 2;
    var XX = sz.add('statictext',undefined, "Intials");
        XX = sz.add('edittext',undefined, "");
        XX.characters = 3;
   
    var repeat = cutHeight;  
    var LF = win2.add('group');
    var layflat = LF.add('statictext', undefined, "Postition of Fold from the left in mm");
    var LFdistance = LF.add('edittext',undefined,"50");
    LFdistance.characters = 8;
         
    var coInfo = win2.add('group');
    var co = coInfo.add('statictext', undefined, "Company");
    var coName = coInfo.add('edittext',undefined,"");
    coName.characters = 30;
    var pInfo = win2.add('group');
    var pNum = pInfo.add('statictext', undefined, "Part Number");
    pNum = pInfo.add('edittext', undefined, "");
    pNum.characters = 30;

    var P = win2.add('group');
    P.alignChildren ="right";
    var pressType = P.add('statictext', undefined, "Press Type");
    var press = P.add('dropdownlist', undefined,["HP Digital", "Flexo"]);
    press.selection = 0;

    var C = win2.add('group');
    C.alignChildren ="right";
    var color = C.add('statictext', undefined, "White");
    var C4 = C.add('dropdownlist', undefined,["No White", "White", "White x2", "White x4"]);
    C4.selection = 0;
    C4.characters = 5;
    var wP = C.add('dropdownlist', undefined,["Full White Ink", "Spot White Ink", "No White Ink"]);
    wP.selection = 0;
    wP.characters = 5;
   
    var SpotC = win2.add('group');
    var spot2 = SpotC.add('edittext', undefined,"");
    spot2.characters = 12;
    var spot3 = SpotC.add('edittext', undefined,"");
    spot3.characters = 12;
    var spot4 = SpotC.add('edittext', undefined,"");
    spot4.characters = 12;
   
    var MT = win2.add('group');
    MT.alignChildren ="right";
    var material = MT.add('statictext', undefined, "Material");
    var MType = MT.add('dropdownlist', undefined,["2183 Clear PVC", "2184 Clear PETG", "2188 Clear OPS"]);
    MType.selection = 0;
      
    var AD = win2.add('group');
    AD.alignChildren ="right";
    var adhesive = AD.add('statictext', undefined, "Slip Coat");
    var ADType = AD.add('dropdownlist', undefined,["Clear Slip Coat", "Varnish Slip Coat", "White Slip Coat", "Clear Slip and Silver Foil"]);
    ADType.selection = 0;
    var whitePrintStatement = dimL.textFrames.add();
   
   
    var fin = win2.add('group');     
    fin.alignChildren ="right";
    var finish = fin.add('statictext', undefined, "Top Coat");
    var fType = fin.add('dropdownlist', undefined,["No Varnish", "Matte Varnish"]);
    fType.selection = 0;

    var core = win2.add('group');
    core.alignChildren ="right";
    var coreSz = core.add('statictext', undefined, "Finish");
    var coreSize = core.add('dropdownlist', undefined, ["6\" Core",  "5\" Core",  "10\" Core", "3\" Core", "Sheeted"]);
    coreSize.selection = 0;
    var stK = core.add('dropdownlist', undefined, ["Rolls of", "Stacks of"]);
    stK.selection = 0;   
    var QTY = core.add('statictext', undefined, "Quantity");
    var QT = core.add('edittext', undefined,"");
    QT.characters = 5;

    var wind = win2.add('group');
    wind.alignChildren ="right";
    var windD = wind.add('statictext', undefined, "Wind Direction");
    var WD = wind.add('dropdownlist', undefined,["1 Out Top First, 2 Out Bottom First", "3 Out Left Side First",
    "4 Out Right Side First", "Fanfold", "Sheeted", "Blank"]);
    WD.selection = 0;
   
    var btns = win2.add('group'); 
    btns.alignChildren = 'center'; 
    btns.margins = [0,10,0,0]; 
    var ok2 = btns.add('button',undefined,"OK"); 
    var cancel = btns.add('button',undefined,"Cancel");
    cancel.onClick = function(){ 
        win2.close(); 
    } 

//--------------------------
ok.onClick = function(){
        var doMathOn = slitWidth.text;
        if (doMathOn % 1 != 0){
            if (doMathOn % 1 > 0.499999) {
                doMathOn = Math.round(doMathOn);
            }else{
                doMathOn = Math.round(doMathOn) + 1;
            }
        }
        slitWidth.text = doMathOn.toString();
  
        app.activeDocument.artboards[0].artboardRect = [0,(cutHeight.text*2.83464566929134)+320,(slitWidth.text*2.83464566929134)+140,0];       
       
        if(chk.value == true){
            draw(0,"Artboard Clip"); 
         } 
    
        if(perf.value == true){
            perfline(0,"Artboard Clip"); 
         } 
    
        if(unit1.value == true){ 
            var bleed = bleedvalue.text * 2.83466796875; // mm 
         } else { 
             var bleed = bleedvalue.text * 72; // inch 
         }
         draw(bleed,"Bleed Clip"); 
         win.close();  
    }         
 
   
    ok2.onClick = function(){
        var doMathOn = labelWidth.text;
        if (doMathOn % 1 != 0){
            if (doMathOn % 1 > 0.499999) {
                doMathOn = Math.round(doMathOn);
            }else{
                doMathOn = Math.round(doMathOn) + 1;
            }
        }
        labelWidth.text = doMathOn.toString();
  
        app.activeDocument.artboards[0].artboardRect = [0,(cutHeight.text*72)+320,(labelWidth.text*72)+140,0];       
       
        if(chk.value == true){
            draw(0,"Artboard Clip"); 
         } 
    
        if(perf.value == true){
            perfline(0,"Artboard Clip"); 
         } 
    
        if(unit1.value == true){ 
            var bleed = bleedvalue.text * 2.83466796875; // mm 
         } else { 
             var bleed = bleedvalue.text * 72; // inch 
         }
         draw(bleed,"Bleed Clip"); 
         win2.close();  
    }         
      if (choise == "Shrink") {win.show();}
       if (choise == "Shrink") {win2.show;}
   //----------------------------
   //CHECK PRINT CYLINDER SIZE
var pcSize = (parseFloat(cutHeight.text/25.4));
var tooth = pcSize
var count =0;

do {
    count = count +1;
    tooth = pcSize * count;
    }
    while (tooth <=11) ;

    tooth = tooth*8;
    tooth = Math.round(tooth);

    repeat = tooth / count / 8;
    alert ("Tooth Size " + tooth); 

    foldGap = LFdistance.text;
    while (foldGap<16){
        foldGap=16;
        }

var sleeve = DL.pathItems.rectangle (((repeat*25.4).toFixed(3)*2.83464566929134)+260, 40,  slitWidth.text*2.83464566929134,
(repeat*25.4).toFixed(3)*2.83464566929134);
    sleeve.stroked = true;
    sleeve.strokeColor = dieColor;
    sleeve.strokeWidth = .5;
    sleeve.strokeOverprint = true;
    sleeve.filled=false;
    sleeve.locked = true;
   
    var sleeve = PrintArea.pathItems.rectangle (((repeat*25.4).toFixed(3)*2.83464566929134)+260, 40,  slitWidth.text*2.83464566929134,
    (repeat*25.4).toFixed(3)*2.83464566929134);
    sleeve.name = 'Can';
    sleeve.stroked = false;
    sleeve.strokeWidth = .5;
    sleeve.strokeOverprint = true;
    sleeve.filled=true;
    sleeve.fillColor = Can;
    sleeve.locked = true;   

    var printA = PrintArea.pathItems.rectangle (((repeat*25.4).toFixed(3)*2.83464566929134)+260 - (2*2.83464566929134), 34.33070866141732, 
    slitWidth.text*2.83464566929134-5.66929133858268, (repeat*25.4).toFixed(3)*2.83464566929134-(4*2.83464566929134));
    printA.stroked = false;
    printA.strokeWidth =.4;
    printA.strokeOverprint = true;
    printA.fillColor = Zero;
   
    var cropAB = WTLayer.pathItems.rectangle (((repeat*25.4).toFixed(3)*2.83464566929134)+260, 17.322834645669288, 
    slitWidth.text*2.83464566929134+22.677165354330709, (repeat*25.4).toFixed(3)*2.83464566929134);
    cropAB.stroked = true;
    cropAB.strokeColor = folds;
    cropABstrokeWidth = .4;
    cropAB.strokeOverprint = true;
    cropAB.filled=false;
   
    var WPrint = WTLayer.pathItems.rectangle (((repeat*25.4).toFixed(3)*2.83464566929134)+260 - (2.25*2.83464566929134),
    34.33070866141732,  slitWidth.text*2.83464566929134-5.811023622047245, (repeat*25.4).toFixed(3)*2.83464566929134-(4.5*2.83464566929134));
    WPrint.name='WhitePrinter';
    WPrint.filled = false;
    WPrint.fillOverprint = true;
    WPrint.stroked = false;
   
    var wSlitGuide = WTLayer.pathItems.rectangle (((repeat*25.4).toFixed(3)*2.83464566929134)+260, 17.322834645669288,
    (17.00787401574804),(repeat*25.4).toFixed(3)*2.83464566929134);
    wSlitGuide.filled=true;
    wSlitGuide.fillOverprint = true;
    wSlitGuide.fillColor = White;
    wSlitGuide.stroked = false;
   
    var kLine = WTLayer.pathItems.rectangle ((repeat*25.4).toFixed(3)*2.83464566929134+260, 22.992125984251966,
    (5.66929133858268), (repeat*25.4).toFixed(3)*2.83464566929134);
    kLine.filled=true;
    kLine.fillOverprint = true;
    kLine.fillColor = Black;
    kLine.stroked = false;
   
    var layFlat = DL.pathItems.rectangle ((repeat*25.4).toFixed(3) *2.83464566929134+260, (foldGap*2.83464566929134+40), 
    (slitWidth.text*2.83464566929134-(8*2.83464566929134))/2,(repeat*25.4).toFixed(3)*2.83464566929134);
    layFlat.stroked = true;
    layFlat.strokeColor = folds;
    layFlat.strokeWidth = .3;
    layFlat.strokeOverprint = true;
    layFlat.filled=false;

    var frontCenter = dimL.textFrames.add();
    frontCenter.contents = 'Front | Center';
    frontCenter.top = 260;
    frontCenter.left = (slitWidth.text-8)*2.83464566929134/4+(foldGap*2.83464566929134+40);
    frontCenter.story.textRange.justification = myJust;
    frontCenter.story.textRange.size = 9;
    frontCenter.story.textRange.fillColor = folds;

//PRINT HEIGHT
    var dashTA = dimL.pathItems.add();
    dashTA.stroked = true;
    dashTA.strokeColor = dieColor;
    dashTA.strokeWidth = .4;
    dashTA.setEntirePath([[slitWidth.text*2.83464566929134+58, ((repeat*25.4).toFixed(3)*2.83464566929134+260)],
    [slitWidth.text*2.83464566929134+48, ((repeat*25.4).toFixed(3)*2.83464566929134+260)]]);
    var dashTB = dimL.pathItems.add();
    dashTB.stroked = true;
    dashTB.strokeColor = dieColor;
    dashTB.strokeWidth = .4;
    dashTB.setEntirePath([[slitWidth.text*2.83464566929134+58, ((repeat*25.4).toFixed(3)*2.83464566929134+254.33070866141732)],
    [slitWidth.text*2.83464566929134+48, ((repeat*25.4).toFixed(3)*2.83464566929134+254.33070866141732)]]);
    var clear = dimL.textFrames.add();
    clear.contents = '2 mm Clear';
    clear.top = (((repeat*25.4).toFixed(3)*2.83464566929134)+264);
    clear.left = slitWidth.text*2.83464566929134+80;
    clear.story.textRange.justification = myJust;
    clear.story.textRange.size = 8;
    clear.story.textRange.fillColor = dieColor;

    var dashBA = dimL.pathItems.add();
    dashBA.stroked = true;
    dashBA.strokeColor = dieColor;
    dashBA.strokeWidth = .4;
    dashBA.setEntirePath([[slitWidth.text*2.83464566929134+58, (265.66929133858268)], [slitWidth.text*2.83464566929134+48, (265.66929133858268)]]);   
    var dashBB = dimL.pathItems.add();
    dashBB.stroked = true;
    dashBB.strokeColor = dieColor;
    dashBB.strokeWidth = .4;
    dashBB.setEntirePath([[slitWidth.text*2.83464566929134+58, 260], [slitWidth.text*2.83464566929134+48, 260]]);
    var clear = dimL.textFrames.add();
    clear.contents = '2 mm Clear';
    clear.top = 271;
    clear.left = slitWidth.text*2.83464566929134+80;
    clear.story.textRange.justification = myJust;
    clear.story.textRange.size = 8;
    clear.story.textRange.fillColor = dieColor;
                //vertical line
    var printLine = dimL.pathItems.add();
    printLine.stroked = true;
    printLine.strokeColor=dieColor
    printLine.strokeWidth = .4;
    printLine.setEntirePath([[slitWidth.text*2.83464566929134+58, ((repeat*25.4).toFixed(3)*2.83464566929134+254.33070866141732)],
    [slitWidth.text*2.83464566929134+58, 265.66929133858268]]);
   
    var printH = dimL.textFrames.add();
    printH.contents =
    'Cut\nHeight\n'+(repeat*25.4).toFixed(3)+' mm';
//    '\n\nPrint\nHeight\n'+((repeat*25.4).toFixed(3)-4)+' mm';
    printH.top = (((repeat*25.4).toFixed(3)*2.83464566929134)/2+280);
    printH.left = slitWidth.text*2.83464566929134+63;
    printH.story.textRange.size = 10;
    printH.story.textRange.fillColor = folds;

// 4MM CLEAR AREA 
var clear = dimL.textFrames.add();
clear.contents = '4 mm Clear Area, No Ink';
clear.top = (((repeat*25.4).toFixed(3)*2.83464566929134)/2+265);
clear.left = (slitWidth.text*2.83464566929134+35);
clear.story.textRange.justification = myJust;
clear.story.textRange.size = 8;
clear.story.textRange.fillColor = folds;
clear.rotate(90);

//SLIT WIDTH
    var dashL1 = dimL.pathItems.add();
    dashL1.stroked = true;
    dashL1.strokeColor = dieColor;
    dashL1.strokeWidth = .4;
    dashL1.setEntirePath([[40, ((repeat*25.4).toFixed(3)*2.83464566929134+275)],
    [40, ((repeat*25.4).toFixed(3)*2.83464566929134+265)]]);

    var dashR = dimL.pathItems.add();
    dashR.stroked = true;
    dashR.strokeColor = dieColor;
    dashR.strokeWidth = .4;
    dashR.setEntirePath([[slitWidth.text*2.83464566929134+40, ((repeat*25.4).toFixed(3)*2.83464566929134+275)],
    [slitWidth.text*2.83464566929134+40, ((repeat*25.4).toFixed(3)*2.83464566929134+265)]]);
   
    var slitWd = dimL.pathItems.add();
    slitWd.stroked = true;
    slitWd.strokeColor=dieColor
    slitWd.strokeWidth = .4;
    slitWd.setEntirePath([[40, ((repeat*25.4).toFixed(3)*2.83464566929134+275)], [(slitWidth.text*2.83464566929134+40),
    ((repeat*25.4).toFixed(3)*2.83464566929134+275)]]);
   
    var slitHtData = dimL.textFrames.add();
    slitHtData.contents = 'Slit Width '+slitWidth.text+' mm' ;
    slitHtData.top = ((repeat*25.4).toFixed(3)*2.83464566929134)+290;
    slitHtData.left = ((slitWidth.text*2.83464566929134-17.00787401574804)/4+(foldGap*2.83464566929134+40));;
    slitHtData.story.textRange.justification = myJust;
    slitHtData.story.textRange.size = 10;
    slitHtData.story.textRange.fillColor = folds;

//LayFlat Edge
    var edgeData = dimL.textFrames.add();
    edgeData.contents = foldGap+' mm';
    edgeData.top = ((repeat*25.4).toFixed(3)*2.83464566929134+275);
    edgeData.left = ((foldGap/2)*2.834645669291339+40);
    edgeData.story.textRange.justification = myJust;
    edgeData.story.textRange.size = 8;
    edgeData.story.textRange.fillColor = dieColor;
   
// LAYFLAT FOLDS
    var dashLF1 = dimL.pathItems.add();
    dashLF1.stroked = true;
    dashLF1.strokeColor = folds;
    dashLF1.strokeWidth = .4;
    dashLF1.setEntirePath([[(foldGap*2.83464566929134+40), ((repeat*25.4).toFixed(3)*2.83464566929134+275)], [(foldGap*2.83464566929134+40),
    ((repeat*25.4).toFixed(3)*2.83464566929134+265)]]);
   
    var dashLF2 = dimL.pathItems.add();
    dashLF2.stroked = true;
    dashLF2.strokeColor = folds;
    dashLF2.strokeWidth = .4;
    dashLF2.setEntirePath([[((slitWidth.text*2.83464566929134-22.67716535433072)/2+(foldGap*2.83464566929134+40)), ((repeat*25.4).toFixed(3)*2.83464566929134+275)],
    [((slitWidth.text*2.83464566929134-22.67716535433072)/2+(foldGap*2.83464566929134+40)), ((repeat*25.4).toFixed(3)*2.83464566929134+265)]]);

    var layflatData = dimL.textFrames.add();
    layflatData.contents = 'Lay Flat  '+(slitWidth.text-8)/2+' mm';
    layflatData.top = ((repeat*25.4).toFixed(3)*2.83464566929134+275);
    layflatData.left = ((slitWidth.text*2.83464566929134-17.00787401574804)/4+(foldGap*2.83464566929134+40));
    layflatData.story.textRange.justification = myJust;
    layflatData.story.textRange.size = 9;
    layflatData.story.textRange.fillColor = folds;
   
    var foldData = dimL.textFrames.add();
    foldData.contents = 'Fold';
    foldData.top = ((repeat*25.4).toFixed(3)*2.83464566929134+275);
    foldData.left = (foldGap*2.83464566929134+45);
    foldData.story.textRange.left = myJust;
    foldData.story.textRange.size = 9;
    foldData.story.textRange.fillColor = folds;
    foldData.story.textRange.overprintFill = true;

    var foldData = dimL.textFrames.add();
    foldData.contents = 'Fold';
    foldData.top = ((repeat*25.4).toFixed(3)*2.83464566929134+275);
    foldData.left = ((slitWidth.text*2.83464566929134-17.00787401574804)/2+(foldGap*2.83464566929134+18));
    foldData.story.textRange.left = myJust;
    foldData.story.textRange.size = 9;
    foldData.story.textRange.fillColor = folds;
    foldData.story.textRange.overprintFill = true;

//CRITICAL ART BOX AND DATA
    var topArtGuide = DL.pathItems.rectangle (((repeat*25.4).toFixed(3)*2.83464566929134)+242-16.69291338582678, 62.677165354330712, 
    slitWidth.text*2.83464566929134-34.015748031496063, (repeat*25.4).toFixed(3)*2.83464566929134-(20*2.83464566929134));
    topArtGuide.stroked = true;
    topArtGuide.strokeColor=folds;
    topArtGuide.strokeWidth = .4;
    topArtGuide.filled = false;
    topArtGuide.strokeOverprint=true;
    var criticalArt = dimL.textFrames.add();
    criticalArt.contents = 'No Critical Art Outside box.';
    criticalArt.story.textRange.justification = myJust;
    criticalArt.story.textRange.fillColor=folds;   
    criticalArt.story.textRange.size = 11;
    criticalArt.story.textRange.overprintFill = true;
    criticalArt.top = (25+(90*2.834645669291339));
    criticalArt.left = (slitWidth.text-8)*2.83464566929134/4+(foldGap*2.83464566929134-29);

//  SEAM OVERLAP
    var seamO = dimL.textFrames.add();
    seamO.contents = 'Seam Overlap Area';
    seamO.top = (((repeat*25.4).toFixed(3)*2.83464566929134)/2+265);
    seamO.left = 52;
    seamO.story.textRange.justification = myJust;
    seamO.story.textRange.size = 9;
    seamO.story.textRange.fillColor = folds;
    seamO.story.textRange.overprintFill=true;
    seamO.rotate(90);
   
   
//ARTBOARD
    function draw(bleed,name){ 
    var docRef = app.activeDocument;   
    var artboardRef = docRef.artboards;  
     
    for(i=0;i<artboardRef.length;i++){   
         var top=artboardRef.artboardRect[1];   
         var left=artboardRef.artboardRect[0];   
         var width=artboardRef.artboardRect[2]-artboardRef.artboardRect[0];   
         var height=artboardRef.artboardRect[1]-artboardRef.artboardRect[3];   
         var rect = docRef.pathItems.rectangle (top+bleed, left-bleed, width+(bleed*2), height+(bleed*2));   
         rect.fillColor = rect.strokeColor = new NoColor();  
         rect.name = name; 
         }   
     } 

var edge = dimL.textFrames.add();

hilite = new CMYKColor();
hilite.cyan = 100;
cyan = new CMYKColor();
cyan.cyan = 100;
magenta = new CMYKColor();
magenta.magenta = 100;
yellow = new CMYKColor();
yellow.yellow = 100;
black = new CMYKColor();
black.black = 100;

// PLACING PROOF INFO

var rndRect = dimL.pathItems.roundedRectangle(225, 40, 130, 150, 7.0, 7.0 );
    rndRect.strokeWidth = .4;
var rndRect = dimL.pathItems.roundedRectangle(225, 180, 100, 150, 7.0, 7.0 );
    rndRect.strokeWidth = .4;
var  colorDot = dimL.pathItems.roundedRectangle(205, 188, 12, 12);
    colorDot.strokeWidth = .4;
    colorDot.fillColor = cyan;
    var  colorDot = dimL.pathItems.roundedRectangle(190, 188, 12, 12);
    colorDot.strokeWidth = .4;
    colorDot.fillColor = magenta;
    var  colorDot = dimL.pathItems.roundedRectangle(175, 188, 12, 12);
    colorDot.strokeWidth = .4;
    colorDot.fillColor = yellow;   
    var  colorDot = dimL.pathItems.roundedRectangle(160, 188, 12, 12);
    colorDot.strokeWidth = .4;
    colorDot.fillColor = black;   
    var  colorDot = dimL.pathItems.roundedRectangle(145, 188, 12, 12);
    colorDot.strokeWidth = .4;
    var  colorDot = dimL.pathItems.roundedRectangle(130, 188, 12, 12);
    colorDot.strokeWidth = .4;
    var  colorDot = dimL.pathItems.roundedRectangle(115, 188, 12, 12);
    colorDot.strokeWidth = .4;
var rndRect = dimL.pathItems.roundedRectangle(225, 290, 100, 150, 7.0, 7.0 );
    rndRect.strokeWidth = .4;
var coInfo = dimL.textFrames.add();
    coInfo.contents =         
        coName.text + '     ' + 'Part #:  ' + pNum.text + '     ' + today +  '     ' + XX.text
        coInfo.top = (cutHeight.text*2.83464566929134)+305;
        coInfo.left = 40;
        coInfo.story.textRange.size = 13;
var sizeCaps = dimL.textFrames.add();
    sizeCaps.contents =       
        'SIZE INFO';
        sizeCaps.top = 220;
        sizeCaps.left = 48;
        sizeCaps.story.textRange.size = 14;
var sizeInfo = dimL.textFrames.add();
    sizeInfo.contents =       
        'Slit Width: ' + slitWidth.text + 'mm (' + parseFloat(slitWidth.text/25.4).toFixed(3) +'\") \n' +
        'Print Width: ' + (slitWidth.text - 2) + 'mm (' + parseFloat((slitWidth.text -2)/25.4).toFixed(3) +'\") \n' +
        'Cut Height: ' + (repeat*25.4).toFixed(3) + 'mm (' + parseFloat(repeat).toFixed(3) + '\") \n' +
        'Lay Flat Width: ' + (slitWidth.text-8)/2 + 'mm' + '  (' + parseFloat(((slitWidth.text-8)/2)/25.4).toFixed(3) + '\')'+ '\n'
        sizeInfo.top = 204;
        sizeInfo.left = 48;
        sizeInfo.story.textRange.size = 10;
        sizeInfo.textRange.characterAttributes.autoLeading = false;       
        sizeInfo.textRange.characterAttributes.leading = 14;  
       
var colorCaps = dimL.textFrames.add();
    colorCaps.contents =       
        'COLOR INFO';
        colorCaps.top = 220;
        colorCaps.left = 188;
        colorCaps.story.textRange.size = 14;
var colorInfo = dimL.textFrames.add();
        colorInfo.contents=
        'Cyan' + '\n' + 'Magenta' +'\n'+ 'Yellow' + '\n'  + 'Black' + '\n' +C4.selection.text + '\n'; 
        colorInfo.top = 206;
        colorInfo.left = 205;
        colorInfo.story.textRange.size = 10;    
        colorInfo.textRange.characterAttributes.autoLeading = false;       
        colorInfo.textRange.characterAttributes.leading = 15;    
var color2 = dimL.textFrames.add();
        color2.contents=
        wP.selection.text + '\nGrey Represents Clear';
        color2.top = 100;
        color2.left = 188;
        color2.story.textRange.size = 10;    
        color2.textRange.characterAttributes.autoLeading = false;       
        color2.textRange.characterAttributes.leading = 11;      
       
var finCaps = dimL.textFrames.add();
    finCaps.contents =       
        'FINISHING';
        finCaps.top = 220;
        finCaps.left = 298;
        finCaps.story.textRange.size = 14;
var finishInfo = dimL.textFrames.add();
        finishInfo.contents=
        ADType.selection.text + '\n' + WD.selection.text+'\n' +
        coreSize.selection.text + '  ' + stK.selection.text + '  ' +  QT.text + '\n' +
        fType.selection.text+ '\n' ;
        finishInfo.top = 204;
        finishInfo.left = 298;
        finishInfo.story.textRange.size = 10;
       
var rndRect = dimL.pathItems.roundedRectangle(225, 400, 115, 150, 7.0, 7.0 );
        rndRect.strokeWidth = .4;
var pressC = dimL.textFrames.add();
    pressC.contents =       
        'PRESS INFO';
        pressC.top = 220;
        pressC.left = 410;   
        pressC.story.textRange.size = 14;
var pressInfo = dimL.textFrames.add();
        pressInfo.contents =       
        press.selection.text  + '\n' + MType.selection.text;
        pressInfo.top = 202;
        pressInfo.left = 410;   
var windCaps = dimL.textFrames.add();
        windCaps.contents =
        'Wind Direction'  + '\n' + ddl.selection;

var placement9pointAlignment = "mm"; 
        windCaps.top = 202;
        windCaps.left = 522;
        windCaps.story.textRange.size = 14;

       
       '\nPrint Cylinder ' + tooth +'T \n â–¼ LEADING EDGE  â–¼';

    var perm = dimL.textFrames.add();
    perm.contents = 'THIS IS ONLY A REPRESENTATION OF COLOR IT IS NOT A COLOR PROOF.';
    perm.top = 20;
    perm.left = 40;
    perm.story.textRange.size = 11; 
    perm.story.textRange.fillColor = folds;
  
    WTLayer.visible = false;

Translate
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