Copy link to clipboard
Copied
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!
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();
}
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.lengt
...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++) {
...
Copy link to clipboard
Copied
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();
}
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();
}
}
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.
4. What's wrong with my var bleedVal that it's not working in the bleedOffsetRect array?
bleedVal is not assigned a value.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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?
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;
}
Copy link to clipboard
Copied
THANK YOU!
I wish I could mark both of your responses as correct. The answers to my questions are in both of your responses. Thank you thank you!
You are correct again. The layer visibility was what was causing the other functions to not repeat correctly. It needs to toggle the variable layers off, but I created a new function to execute right before the processLayers which would allow the previous (embed/outline) functions to loop fully.
bleedVal just shows my ineptitude. Thanks for fixing that as well!
You're amazing! Can't say thanks enough. I've been struggling to make these fixes to the script for TOO long.
Copy link to clipboard
Copied
You're welcome.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more