Script Works when Selected Through File->Scripts but Breaks When Action is Used
- December 27, 2022
- 2 replies
- 938 views
Hi!
First time poster here, and not the best at scripting for AI, so please bear with me. 🙂
The synapsis of my issue appears to lie within an action I have recorded to run a script for the printing company I work at. This script is meant to generate custom size templates for the flags we print based on user input (the flag finishing "style", size, whether it is single or double sided).
When building the script, I have been running it to test it by going to the File menu, and then selecting the script I have been cretaing through Scripts->[the script name, we'll call it "Flag Tool"]. When I call the script this way, everything works fine and the templates generate as intended with the correct bleed, finished size, "safe area", etc.
However, when I was having some peers test out this tool, they had been using an action to call the script, and the tool completely breaks when doing any of the "double sided" flag options (which entails a second artboard being created and the "template" lines being rotated 180 degrees for the "back" side of the flags).
To give a run-down of what the tool is supposed to do:
- Generates the bleed area, "safe area", and finished area based on a user-entered size. Puts these three items on its own non-printing layer labeled "Template".
- Generates a thru-cut line in a specific swatch color on its own locked layer.
- If the flag is selected as double-sided, the tool then duplicates the artboard.
- Template layer is selected by itself from the first artboard and copied over to the second (pasted in place).
- The thru-cut layer is then copied and pasted in place in a similar fashion on the appropriate layer.
- The template layer on the seconmd artboard is then selected and rotated 180 degrees to "flip" the template for the back side of a flag.
These functions all work very well when the script is selected form the File menu, however, when an action is created to call the script, the tool encounters some strange errors in which the template layer is copied/pasted twice, is not rotated, and is pasted on the wrong layer (it ends up pasted on the cut-sontour layer, which I explicitly put in the code to not do).
I am at a complete loss as to why using an action that simply calls for the script is breaking the script so severely when just running the script manually fromt he File menu works pereectly fine. My colleagues seem to strongly prefer to use actions instead of manually selecting the scripts because it allows them to assign keybinds for a faster workflow. Does anyone have any advice on how to remedy this issue?
I have attached some screenshots of what the tools is generating when I use File->Scripts vs. when I use the action we have created (by just recording a new action in a new action folder and then using Insert Menu Itemand to select the script). There is also an error message regarding the selection, and I am not sure why that comes up becuase it works fine when I am not using the action and am just running the script. I am just super stumped!
