-
1
- #1
I ran into a problem the other day while running a custom Python script in Corels' Paint Shop Pro Photo X2. The script was created using the 'Record' option under the File|Script menu. I found that when I ran the script as a Batch Process it would randomly fail on certain png files. The script would generate the following error but never on the same file twice:
Error Text: The attempted operation is not valid in the current program state.
When I searched Tek Tips I found this thread:
This thread accurately descries the problem, but it unfortunately did not provide a solution. Here is the fix:
The script appears to be running too fast. I have noticed this only in scripts that are running as a Batch Process and only when the script tries to SAVE the file after it makes its modifications.
In order for the script to run properly you must pause the script at some point to give the software a chance to catch up. You can do this simply by adding a few lines to the script that will cause the script to pause for a second or two.
First locate your script file. The easiest way to this across all windows platforms is to just search for it. The file name is YourScriptName.PspScript. For example my script was called AutoCrop so the filename for the script is AutoCrop.PspScript. Once you have located the file, open it with notepad.
At the very top of your script, add this line:
It is important that this is the first line in the script.
Now, at any point in the script add this line:
I recommend putting this line at the very bottom of the script so that it is the last line in the file. All this does is tells the script to pause for 1 second before it ends. If you wish, you could change the 1 to another number to increase the amount of seconds the script pauses. This will give PaintShopPro enough time to finish what ever it needs to do before the script runs again on another file as part of the Batch process.
Save your script and give it a try! The only drawback of course is that your script will now run more slowly, but hey, at least it will work!
Hope this helps someone....
Error Text: The attempted operation is not valid in the current program state.
When I searched Tek Tips I found this thread:
This thread accurately descries the problem, but it unfortunately did not provide a solution. Here is the fix:
The script appears to be running too fast. I have noticed this only in scripts that are running as a Batch Process and only when the script tries to SAVE the file after it makes its modifications.
In order for the script to run properly you must pause the script at some point to give the software a chance to catch up. You can do this simply by adding a few lines to the script that will cause the script to pause for a second or two.
First locate your script file. The easiest way to this across all windows platforms is to just search for it. The file name is YourScriptName.PspScript. For example my script was called AutoCrop so the filename for the script is AutoCrop.PspScript. Once you have located the file, open it with notepad.
At the very top of your script, add this line:
Code:
import time
It is important that this is the first line in the script.
Now, at any point in the script add this line:
Code:
time.sleep(1)
I recommend putting this line at the very bottom of the script so that it is the last line in the file. All this does is tells the script to pause for 1 second before it ends. If you wish, you could change the 1 to another number to increase the amount of seconds the script pauses. This will give PaintShopPro enough time to finish what ever it needs to do before the script runs again on another file as part of the Batch process.
Save your script and give it a try! The only drawback of course is that your script will now run more slowly, but hey, at least it will work!
Hope this helps someone....