Skip to main content
Participating Frequently
June 11, 2021
Answered

Script help for outlining text and embedding links WHEN selected

  • June 11, 2021
  • 1 reply
  • 1798 views

So, I'm creating modifications to a script that was written already. It shows a prompt and has checkboxes. It's over my head, but I feel like I'm close.

The main things I need help understanding are:

1. How do I get the w.btns.btn2.onClick to perform 3 functions in order?

2. How do I get the embedLinks function to execute IF the checkbox is selected and get it to repeat on all placedItems? I can get it to embed the first image, but not all of them.

3. How do I get the outlineText to grab all text frames? For some reason it's only outlining the first layer.

4. What's wrong with my var bleedVal that it's not working in the bleedOffsetRect array?

 

I'm getting things to work part-way (for 1 layer or something) but I just can't quite figure out how to get it all to work together. Any help is greatly appreciated!

This topic has been closed for replies.
Correct answer femkeblanco
quote

The outlineText is still only running on my first layer though. ... I really want it to embed the EPS, then outline all text. Do you have any ideas on how I can change the script to manage that?

 

The problem may be the layers being made visible, invisible, visible, invisible, et cetera, the logic of which is not so easy to follow.  Some layers being invisible can cause unexpected behavior.  Try deleting or commenting out this (lines 29-31 or thereabouts)

for (i=0; i<variablelayers.length; i++) {
    variablelayers[i].visible = false;
}

Is making the layers invisible necessary?  If so, can it be done after outlining the text?

 

quote

Also, for the bleedVal, it's supposed to be the if/else immediately below, but if I put bleedVal =, then it won't recognize the "if".

 

Presumably you want this

var bleedVal;
if (w.bleeds.row1.bleedmark.value == true) {
    bleedVal = 10;
} else {
    bleedVal = 0;
}

 

1 reply

femkeblanco
Legend
June 12, 2021
quote

1. How do I get the w.btns.btn2.onClick to perform 3 functions in order?

 

You list your function calls, in order, inside onClick.  E.g. 

function okClick() {
    embedLinks();
    outlineText();
    // processLayers();
    w.close();
}

 

quote

2. How do I get the embedLinks function to execute IF the checkbox is selected and get it to repeat on all placedItems? I can get it to embed the first image, but not all of them.

 

Your loop condition is faulty.  E.g. at iteration 3 out of 3, i = 2, placedItems.length = 1 and the condition is not met.  One way to fix this is

function embedLinks() {
    if (w.links.row1.linkembed.value = true); 
        // for (var i = 0; i < app.activeDocument.placedItems.length; i++) {
        while (app.activeDocument.placedItems.length > 0) {
            placedArt = app.activeDocument.placedItems[0];
            placedArt.embed();
        }
}

 

quote

3. How do I get the outlineText to grab all text frames? For some reason it's only outlining the first layer.

 

That's not what I get from calling outlineText().  It outlines all textFrames on all layers.

 

quote

4. What's wrong with my var bleedVal that it's not working in the bleedOffsetRect array?

 

bleedVal is not assigned a value.

 

Participating Frequently
June 14, 2021

YES! Thank you! I'm not a programmer/scriptor, I just follow enough to try to imitate what I've seen. I thought the onClick function was right, but silly me I forgot the parenthesis. The embed links loops works perfectly, thank you so much. I have 2 more questions for you.

 

The outlineText is still only running on my first layer though. Here's how my test file is setup: It's a barcode sticker, so I have 3 layers, _Artwork, which gets ignored in the static array, then 2 barcode layers with an EPS and UPC sku text. Those layers have the SKU as they're title. When I run the script, it's only outlining sku 1. I really want it to embed the EPS, then outline all text. Do you have any ideas on how I can change the script to manage that?

 

Also, for the bleedVal, it's supposed to be the if/else immediately below, but if I put bleedVal =, then it won't recognize the "if".

 

Again, SUPER appreciate the response and help!

femkeblanco
femkeblancoCorrect answer
Legend
June 16, 2021
quote

The outlineText is still only running on my first layer though. ... I really want it to embed the EPS, then outline all text. Do you have any ideas on how I can change the script to manage that?

 

The problem may be the layers being made visible, invisible, visible, invisible, et cetera, the logic of which is not so easy to follow.  Some layers being invisible can cause unexpected behavior.  Try deleting or commenting out this (lines 29-31 or thereabouts)

for (i=0; i<variablelayers.length; i++) {
    variablelayers[i].visible = false;
}

Is making the layers invisible necessary?  If so, can it be done after outlining the text?

 

quote

Also, for the bleedVal, it's supposed to be the if/else immediately below, but if I put bleedVal =, then it won't recognize the "if".

 

Presumably you want this

var bleedVal;
if (w.bleeds.row1.bleedmark.value == true) {
    bleedVal = 10;
} else {
    bleedVal = 0;
}