Skip to main content
Participating Frequently
October 7, 2020
Answered

Running action with script not working

  • October 7, 2020
  • 3 replies
  • 2535 views

Hello. I am working with a programmer to write a script for me to automate some of our production work in our print shop. I have a set of actions and he wrote a script to run this action set but when it goes to the first command, "addcutcontourswatch" I always get an error that that object is not avaialble.

 

I have all the neccessary scripts loaded in the script folder but cannot get past the first step.

 

Any ideas?

This topic has been closed for replies.
Correct answer Silly-V

Hey, I used to do this by making an action that would place a single ai file which contains a spot-color cut contour swatch. When I pressed the button, it would automatically place the rectangle into my active document from the filesystem and immediately delete the swatch. Now the spot color is in the active document!

But to help you with your script, we really need to see what the code is. It could be anything and everything.

 

After watching your video the problem is clear: your add cutcontour swatch is created by a script, which is played by an action. But you are also trying to run that action by a script in the 2nd round when it doesn't work. That is because, well, it doesn't work like that. You can only play an action from a script that has no scripts, or you can play an action that has a script, but only from inside Illustrator.

For your swatch needs though, you really don't need a programmer because you can use my technique and simply place & delete a rectangle. When you do need a programmer, keep in mind the action-script interoperability so that you guys don't write a huge library around your current perception and it doesn't work.

3 replies

pixxxelschubser
Community Expert
October 7, 2020

@Silly-V 

You are always welcome.

🙂

pixxxelschubser
Community Expert
October 7, 2020

Only as a sidenote:

It is always better to do what is possible in one script without additional actions (or an action without script). Use such combinations only for app functions which are not available in the scripting engine (or in case that an action is much much more quicker as for example time consuming loops through the whole artwork).

 

Creating a swatch is easy possible with scripting. There is no need to use an action for that.

 

my 2 cent

Silly-V
Brainiac
October 7, 2020

I belive actions can be a nice tool for a versatile workflow because the users can change their own actions and even use some sort of system with scripting to inject parameters, etc. Creating a swatch is possible with scripting, but if they wanted to change the swatch.. with the action they wouldn't even have to necessarily change the action, just the referenced file. Furthermore a script can choose which action to run, so that is dynamic, but on top of that the place can replace the swatch file too, even more control. Of course you can do all sorts of data-storing and web-api stuff to do all-code, but that's more work and takes a longer time. When the users can make as many actions (with an informed perspective of course), they can begin testing and work sooner, even if the actions take forever to execute and the whole thing needs porting over to a full script later - they can start working now and earning something with what they have to later invest in a more technically-intensive solution.
One day I'll need to do a Europe tourist vacation and drop by if I may!

Silly-V
Silly-VCorrect answer
Brainiac
October 7, 2020

Hey, I used to do this by making an action that would place a single ai file which contains a spot-color cut contour swatch. When I pressed the button, it would automatically place the rectangle into my active document from the filesystem and immediately delete the swatch. Now the spot color is in the active document!

But to help you with your script, we really need to see what the code is. It could be anything and everything.

 

After watching your video the problem is clear: your add cutcontour swatch is created by a script, which is played by an action. But you are also trying to run that action by a script in the 2nd round when it doesn't work. That is because, well, it doesn't work like that. You can only play an action from a script that has no scripts, or you can play an action that has a script, but only from inside Illustrator.

For your swatch needs though, you really don't need a programmer because you can use my technique and simply place & delete a rectangle. When you do need a programmer, keep in mind the action-script interoperability so that you guys don't write a huge library around your current perception and it doesn't work.

Participating Frequently
October 7, 2020

Hello. Thanks for the input. I uploaded a video to show the script and the first action failing. This is just a test script, not the one the programmer is working on.

 

app.doScript("Action 1","Set 1") is the script I am running. It should run the action I have in my panel. I get an error message saying the "addcutcontourswatch" is unvailable. I have 'addcutcontourswatch' in my scripts folder. I can run it fine using the play button.

 

Silly-V
Brainiac
October 7, 2020

The input is your answer and solution.