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

Scripts for proofing on a template

New Here ,
May 10, 2020 May 10, 2020

Copy link to clipboard

Copied

Hello community,

I operate a company that produces custom apparel, promo items, etc. I want to enable my employees to produce proofs accurately and quickly by using scripting on our existing (or a new) Illustrator template. Currently, the Illustrator tempalte is comprised of layers with various product mockups as well as information for communication internally, to clients, and to vendors (for example, job name, ink colors, etc). We strive to use a single file for both customer facing proofing and production to minimize possibility for error as well as to minimize touchpoints. I've read through some other threads and don't think I have the capability to figure this out completely on my own, but would be happy to contract with someone who can, or else if someone has some helpful tidbits on where to begin, they would be much appreciated. 

 

Key functions I would like to have:

- Ability to paste in a vector file, resize (at fixed proportion) and position on product automatically

- Ability to toggle layers or otherwise display pertinent information based on certain parameters (something like button mode in Actions, where someone could just click the parameters that apply, and appropriate changes occur to the document). 

 

Nice to haves:

- Ability to create text box with print size (pulled from dimensions of grouped image / art) 

- Ability to autosave document with PDF parameters set

- Ability to save document with Job name from within document. i.e., pull text from the layout as the document name when saving -- JOBNAME0520_layout.pdf. 

 

I've only been researching this for about an hour, so I literally have no idea if it's possible, but it doesn't seem that actions will meet any of my goals. Any help would be much appreciated. Feel free to contact here or [Removed Email add by Moderator]

 

Thanks

 

 

TOPICS
Scripting

Views

516

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
LEGEND ,
May 10, 2020 May 10, 2020

Copy link to clipboard

Copied

LATEST

@loganr88

Everything you discribe is doable through scripting. I have been on a similar two-year quest for my company and with the help of many on this forum have built a set of JavaScript functions that do many of the things you discribe. 


One piece of the puzzle that made the task much easier for me is a Mac-only app called "Keyboard Maestro".  If you are mac-based its worth a serious look. It provides many cabilities that require no custom scripting. It also allows for you to trigger scripts via custom keyboard shortcuts, time, system event, etc. 


My advice is to start small and automate a very small portion of the overall workflow then build on it as you learn more.

Your first feature might be a good place to start: - Ability to paste in a vector file, resize (at fixed proportion) and position on product automatically.

 

Here are 3 functions for "Pasting", "Aligning" and "Scaling" artwork. They may be edited for your specific needs or give you an idea where to start.

pasteFingerprint("");
alignToObj(true, 0, 0, "FingerprintAlign");
scaleCroppedPrint("Charm Oval Sterling Silver", "Mask");

function pasteFingerprint(oneTwo) {
    var aDoc = app.activeDocument;
    var sel = aDoc.selection;
    var ilayer = aDoc.layers["FINGERPRINT" + oneTwo];
    ilayer.visible = true;
    aDoc.activeLayer = ilayer;

    //Paste Fingerprint
    app.paste();
    app.executeMenuCommand("sendBackward");

    var AlignObj = aDoc.pageItems["FingerprintAlign" + oneTwo];
    if (oneTwo == '2'){
        AlignObj.parent.visible = true;
        }
}

function alignToObj(vertAlign, h_offset, v_offset, myAlignObj) {
    var aDoc = app.activeDocument;
    var sel = aDoc.selection;
    var keyCenter = getCenterPoint(aDoc.pageItems[myAlignObj]);
    var curItem, curCenter;
    const ALIGNMENT_PREFERENCE_VERTICAL = vertAlign;
    const ALIGNMENT_PREFERENCE_HORIZONTAL = true;

    for (var x = 0, len = sel.length; x < len; x++) {
        curItem = sel[x];
        if (ALIGNMENT_PREFERENCE_HORIZONTAL) {
            //align the object horizontally
            curItem.left = keyCenter.h - curItem.width / 2 + h_offset;
        }
        if (ALIGNMENT_PREFERENCE_VERTICAL) {
            //align the object vertically  
            curItem.top = keyCenter.v + curItem.height / 2 + v_offset;
        }
    }
}

function scaleCroppedPrint(product, target) {
    //Scale Selection to Mask
    var aDoc = app.activeDocument;
    var print = aDoc.selection[0];
    var mask = aDoc.pathItems[target];
    var maskW = mask.width;
    var maskH = mask.height;
    var printW = print.width;
    var printH = print.height;
    var scaleX = maskW / printW * 100;
    var scaleY = maskH / printH * 100;

    if (scaleX < scaleY) {
        print.resize(scaleY, scaleY);
    } else {
        print.resize(scaleX, scaleX);
    }
    if (product == "Generic") {
        print.resize(125, 125);
    }
    if (product == "Tie Tack Sterling Silver") {
        print.resize(112, 112);
    }
}

 

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