Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe Illustrator I need to run the script with the ui with certain settings

  • I need to run the script with the ui with certain settings

     peter jenkinson updated 1 year ago 1 Member · 1 Post
  • peter jenkinson

    September 19, 2019 at 9:59 am

    Hi guys i really need help
    I want this script to run but without the ui
    because it need to batch a lot of files out

    I need just these settings to be used
    https://pasteboard.co/Iy72osM.png

    let me know if you need more info?


    /////////////////////////////////////////////////////////////////
    //Select Paths By Size v.3.0.0.0 -- CS, CS2, CS3,CS4 (Change extension from 'jsx' to 'js' to run in CS)
    //>=--------------------------------------
    // Selects all Path Objects, smaller/larger than given threshold
    // Only works for path and compound path objects.
    //
    // If paths are selected, script runs on selected items only,
    // If nothing is selected, script runs on all paths in document.
    // ::: Updates in V2 :::
    // • Rebuilt to select based on Size, Area, Width or by Height.
    // • Added "same size as" option
    // • If one object is selected, starts threshold at that size.
    // • Added Tool Tips
    // ::: Updates in V3 :::
    // • Added status indicator
    // • Rebuilt processing engine so it's faster and more accurate
    //>=--------------------------------------
    // JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com
    //copyright full text here: https://www.wundes.com/js4ai/copyright.txt
    //////////////////////////////////////////////////////////////////

    /* Notes:
    */

    if (app.documents.length > 0)
    {
    var doc = app.activeDocument;

    var sel = doc.selection;
    var defaultValue = .05;
    if (sel.length == 1)
    {
    var seed = (sel[0].width + sel[0].height) /2;
    if (seed != 0 || seed != null)
    {
    defaultValue = seed;
    }
    }

    var OK = 1;
    var by = "none";// flag for what method to walk objects selection/doc
    var tolerance = .005;

    var myVersion = Math.floor(version.split(".")[0]);

    if (myVersion == 12 || myVersion == 11)
    {
    try{
    //if version is CS2
    var tVar = prompt("Enter the numeric threshold, use '>' for greater than and '<' for less than,n i.e.; '>50' would mean 'greater than 50', to match exactly, just enter a number.","<"+defaultValue);// dlg.alertBtnsPnl2.slide.value;
    if (tVar == null)
    {
    OK=3;
    throw("end");
    }
    var tArr = tVar.split("");
    var threshold = tVar;
    var GT = false;
    var LT = false;
    var EQ = false;
    if (tArr[0] == "<")
    {
    LT = true;
    threshold = tVar.substr(1);
    } else if (tArr[0] == ">")
    {
    GT = true;
    threshold = tVar.substr(1);
    } else {
    EQ = true;
    }
    var CP_on = confirm("Include compound path objects?");
    var includeLocked = confirm("Include locked objects?");
    var dVal = prompt("Enter method for comparison, ('s'=size,'w'=width,'h'=height,'a'=area)","s");
    if (dVal == null)
    {
    OK=3;
    throw("end");
    }

    var dims = "size";
    if (dVal == "w")
    {
    dims = "width";
    } else if (dVal == "h")
    {
    dims = "height";
    }else if (dVal == "a")
    {
    dims = "area";
    }
    }
    catch(e){
    // use "OK" values instead...
    }

    } else if (myVersion > 12)
    {
    //use advanced functionality
    //--------------------------Dialog Box Code --------------------------------------------------------
    var dlg = new Window('dialog', 'Select Path Items:');
    dlg.location = [500,50];
    // [startX, StartY, EndX, EndY]
    dlg.alertBtnsPnl1 = dlg.add('group', undefined, 'Path Objects Size:');
    // Radio Buttons for Larger than, or smaller than
    (dlg.alertBtnsPnl1.selectLT = dlg.alertBtnsPnl1.add('radiobutton', [15,15,95,35], 'Smaller than' )).helpTip = "Select all Path ItemsnSmaller thann the Slider Value.";
    (dlg.alertBtnsPnl1.selectSS = dlg.alertBtnsPnl1.add('radiobutton', [15,15,75,35], 'Exactly' )).helpTip = "Select all Path ItemsnThe Same value asn the Slider Value.";
    (dlg.alertBtnsPnl1.selectGT = dlg.alertBtnsPnl1.add('radiobutton', [15,15,95,35], 'Larger than' )).helpTip = "Select all Path ItemsnLarger than n the Slider Value.";

    dlg.alertBtnsPnl1.selectLT.value = true;
    dlg.alertBtnsPnl1.orientation='row';
    // Set Size of threshold
    dlg.alertBtnsPnl2 = dlg.add('group',undefined, 'Threshold:');
    (dlg.alertBtnsPnl2.slide = dlg.alertBtnsPnl2.add('slider', [25,15,165,39], 'Set size of threshold object:')).helpTip = "Use Slider to set a threshold value.";
    dlg.alertBtnsPnl2.slide.value = defaultValue;
    (dlg.alertBtnsPnl2.titleEt = dlg.alertBtnsPnl2.add('edittext', [100,15,160,35], dlg.alertBtnsPnl2.slide.value)).helpTip = "Enter a threshold value.";
    dlg.alertBtnsPnl2.titleEt.text = roundOff(defaultValue);
    (dlg.alertBtnsPnl2.titleSt = dlg.alertBtnsPnl2.add('statictext', [15,15,35,35], 'px')).helpTip = "Pixels.";
    dlg.alertBtnsPnl2.orientation='row';

    (dlg.dimsPnl = dlg.add('panel', undefined, 'In:')).helpTip = "How paths will be compared";
    dlg.dimsPnl.orientation='row';
    (dlg.dimsPnl.selectS = dlg.dimsPnl.add('radiobutton', [15,15,65,35], 'Size' )).helpTip = "(Width * Height) / 2";
    (dlg.dimsPnl.selectA = dlg.dimsPnl.add('radiobutton', [15,15,65,35], 'Area' )).helpTip = "The Items (internal) Area Value.n Note: Open paths have no area.";
    (dlg.dimsPnl.selectW = dlg.dimsPnl.add('radiobutton', [15,15,70,35], 'Width' )).helpTip = "Select by Width ONLY";
    (dlg.dimsPnl.selectH = dlg.dimsPnl.add('radiobutton', [15,15,65,35], 'Height' )).helpTip = "Select by Height ONLY";
    dlg.dimsPnl.selectA.value = true;

    dlg.dimsPnl.selectS.onClick= setTextS;
    dlg.dimsPnl.selectH.onClick= setTextH;
    dlg.dimsPnl.selectA.onClick= setTextA;
    dlg.dimsPnl.selectW.onClick= setTextW;

    // Add a checkbox to control selection
    dlg.alertBtnsPnl3 = dlg.add('group', undefined, '');
    (dlg.hasBtnsCb = dlg.alertBtnsPnl3.add('checkbox', [25,25,235,39], 'Include Compound Path Items?')).helpTip=" Select items within compound paths too.";
    (dlg.incLocked = dlg.alertBtnsPnl3.add('checkbox', [25,25,235,39], 'Include Locked Items?')).helpTip=" Note: This unlocks everything.";
    dlg.hasBtnsCb.value = true;
    dlg.incLocked.value = false;
    dlg.alertBtnsPnl3.orientation='column';

    dlg.btnPnl = dlg.add('group', undefined, 'Do It!');
    dlg.btnPnl.orientation='row';
    dlg.btnPnl.buildBtn1= dlg.btnPnl.add('button',[15,15,115,35], 'Cancel', {name:'cancel'});
    dlg.btnPnl.buildBtn2 = dlg.btnPnl.add('button', [125,15,225,35], 'OK', {name:'ok'});
    dlg.alertBtnsPnl2.slide.onChange= sliderChanged;
    dlg.alertBtnsPnl2.titleEt.onChanging = eTextChanged;
    dlg.btnPnl.buildBtn1.onClick= actionCanceled;
    dlg.show();

    // Translate dialog here:
    var threshold = 1*(dlg.alertBtnsPnl2.titleEt.text);// dlg.alertBtnsPnl2.slide.value;
    var CP_on = dlg.hasBtnsCb.value; //false; // ! confirm("Ignore compound path objects?");
    var GT = dlg.alertBtnsPnl1.selectGT.value;
    var EQ = dlg.alertBtnsPnl1.selectSS.value;
    var LT = dlg.alertBtnsPnl1.selectLT.value;
    var includeLocked = dlg.incLocked.value;
    var dims = "size";
    if (dlg.dimsPnl.selectW.value)
    {
    dims = "width";
    } else if (dlg.dimsPnl.selectH.value)
    {
    dims = "height";
    }else if (dlg.dimsPnl.selectA.value)
    {
    dims = "area";
    }
    } else {
    OK = 2; // alert and close with "version" message
    }// end version check

    //--------------------------Main Code Section --------------------------------------------------------

    var dObj = new Date();
    var start = dObj.getTime();
    var niceTime = (dObj.getMonth( )+1)+"-"+dObj.getDay( )+"-"+dObj.getFullYear( ).toString().substr(2)+"_"+dObj.getHours( )+"."+dObj.getMinutes( )+"."+dObj.getSeconds( );

    if(OK==1){

    var pointTextRef = doc.textFrames.add();
    pointTextRef.selected = false;
    pointTextRef.top = doc.height/2;
    pointTextRef.left = doc.width/2;
    var selItems = new Array();
    pointTextRef.contents = "Pre-Processing!!!";
    redraw();

    if(doc.selection.length >1){
    by = "selection";
    pointTextRef.top = selection[0].top;
    pointTextRef.left =selection[0].left;
    redraw();
    // deselect Compound path items if not included
    var cpLen = doc.compoundPathItems.length;
    for (var cp=0;cp

Viewing 1 of 1 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can. Our Privacy policy | GDPR Policy