PSP 2019, trying to do the following:
Start with a transparent raster layer
Iterate
Open a PSP file with a mostly transparent image, but with a single slice of opaqueness
SelectDocument(1) to go to newly opened document
Select All (this is the mostly transparent slice image)
Copy
SelectDocument(-1) to go to the original base document
#NewRasterLayer (Script fails with or without this step)
SelectAll
PasteIntoSelection (this is done to preserve the positioning of the slice within the transparency)
SelectNone
#LayerMergeDown (fails with or without this)
SelectDocument 1 (should take us back to the recently opened slice document)
FileClose
On the "PasteInto" command a "RuntimeError: The specified command cannot execute in this context."
I have tried numerous rearrangements of the various steps in this script
Any help would be appreciated
Sorry to say it varies as to which iteration it occurs on. And this script used to work just fine (with different data inputs)
Thanks very much
Dean
Please Help with "...command cannot execute in this context"
Moderator: Kathy_9
-
dangelic0
- Posts: 36
- Joined: Sat Oct 22, 2011 4:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Dell XPS 8920
- processor: Core i7-7700 4.2 GHx
- ram: 32GB
- Video Card: NVIDIA GeForce GTX 1060 6GB
- sound_card: Realtek High Definition Audio
- Hard_Drive_Capacity: 4 TB
- Monitor/Display Make & Model: LG Ultra HD
- Corel programs: PSP. VSP
-
JoeB
- Posts: 2778
- Joined: Fri Mar 28, 2008 10:04 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: LENOVO 4524PE4 ThinkCentre M91p
- processor: 3.10 gigahertz Intel Quad Core i5-2400
- ram: 8 GB
- Hard_Drive_Capacity: 4.6 TB
- Corel programs: PSP 9, X7 to 2019, 32 & 64-bit
- Location: Canada
Re: Please Help with "...command cannot execute in this cont
It might be easier for someone to troubleshoot if you were to put that script in a zip file and then post the zip file here as an attachment. Don't try posting the script without zipping it because that changes the space formatting.
Also, you say that this worked before "with different data input". I'm not sure what you mean by that. Was it a slightly different script? Did it have a different purpose? Perhaps you could zip that one also and post it along with the problem script, and give more detail about what you meant by different data inputs.
Also, you say that this worked before "with different data input". I'm not sure what you mean by that. Was it a slightly different script? Did it have a different purpose? Perhaps you could zip that one also and post it along with the problem script, and give more detail about what you meant by different data inputs.
Regards,
JoeB
Using PSP 2019 64bit
JoeB
Using PSP 2019 64bit
-
dangelic0
- Posts: 36
- Joined: Sat Oct 22, 2011 4:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Dell XPS 8920
- processor: Core i7-7700 4.2 GHx
- ram: 32GB
- Video Card: NVIDIA GeForce GTX 1060 6GB
- sound_card: Realtek High Definition Audio
- Hard_Drive_Capacity: 4 TB
- Monitor/Display Make & Model: LG Ultra HD
- Corel programs: PSP. VSP
Re: Please Help with "...command cannot execute in this cont
Yes Joe - That makes sense. I will try to figure out how to do that. The script is attached, but the "other data" I was referring to are other images and/or input configurations to the script. For example, it takes a variable number of files to load, and a variable sequence order in which to load them. I will see if I can reproduce in a somewhat more constrained way.
The failing configuration has 75 folders each with 75 slice images
The failing configuration has 75 folders each with 75 slice images
- Attachments
-
- LoadSlices.zip
- (1.89 KiB) Downloaded 195 times
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Please Help with "...command cannot execute in this cont
As I am on the road, on my phone, I cannot run this script. And if I could, I'm not sure it would matter. Also not certain about matching your format of Time_### and Slc_### for folder and number names with specific slice numbers.
I am curious about your use of a count plus a suffix list. They only seem to serve to double check each other, nothing else. But that's not important here.
I'd like to discuss your use of SelectDocument. I know, you said it fails regardless of whether you use SelectDocument and because I can't actively test it I can only go by what I see and it should work just fine. Just to make sure let me run through the basics. There are two types of documents in scripts: TargetDocument (the document the script will act on) and ActiveDocument (the document currently active in the UI). SelectDocument 0 will set the TargetDocument to equal the ActiveDocument. SelectDocument 1 will move forward one document, SelectDocument -1 will move backwards. If you can't move backwards -1 or can't move forwards 1 then TargetDocument is not changed. If Strict is set to True an error will be thrown. If it's False it fails silently. If there are no images, or if all images but one are removed the TargetDocument is always set to the only open image without the need for SelectDocument. If multiple images are open, and the current targetdocument is closed the new target will be the last opened image in the list.
i'm assuming the workspace is not empty, simply because of how you're using SelectDocument but I will present both an empty and a full workspace in my scenarios.
So running your code through my head it looks like this.
1) You initialize the script by setting The TargetDocument to the currently Active Document. A bit redundant as they will be one and the same upon first run of the script unless you start with an empty workspace.
2) You grab all folders that match each index, expecting to find only one or at least only caring about the first one.
3) You grab all files that match the index, again only caring about the first one assuming there even could be other files matching the format you're looking for. Chances are there are not unless they have .*.* filenames before or after the pattern.
4) You commented out SelectDocument 1. Which if the workspace was empty would fail, if it wasn't would select the next available image in the list. So, depending on the state of the workspace when you ran the script would work like this.
If the workspace had a document open already
Removing the SelectDocument 1 would mean that all actions are executed on the current TargetDocument and never on the newly opened document.
If the workspace was empty
Removing the SelectDocument 1 would do nothing at all. SelectDocument1 would fail but TargetDocument would point to the newly opened image anyway because it needs a target and that's the only available image.
5) You do Select All
6) You do copy, which will fail if there is nothing to copy
7) You do file close
Again, at this point the script will change Targets if the current target was closed. Because you commented out SelectDocument this all depends on the state of the workspace.
With SelectDocument Commented out you get this
1) If workspace was empty, TargetDocument was the document that was just closed. It'll fail to create a new layer as there is no document open. Obviously not your problem.
2) If workspace had an open image already, Select Document was commented out so current you closed your original image, You are now working on the last opened image as the Target
With SelectDocument available you get thsi
1) If workspace was empty, SelectDocument Fails, TargetDocument doesn't change, you closed the current document, it'll fail to create a new layer as there is no document open. Again, obviously not the problem.
2) You had previously selected the next document in the list, TargetDocument pointed to that document, that document was closed, TargetDocument was reset to the last opened image. You run SelectDocument -1 if there is no -1, SelectDocument fails and TargetDocument remains last opened image.
8) You create a new raster layer on this new image
9) You do SelectAll on the new image
10) You paste into selection on new image
11) You increase the slice, select the next folder in the list and look for this new slice.
Does this match what you're seeing? Again just running through it in my head. SelectDocument Should work just fine. Though the easiest option would be to remove SelectDocument -1 and change SelectDocument 1 to SelectDocument 0.
SelectDocument 0 will set the newly opened image as the new target. Then when this image is closed, TargetDocument will once again become the last opened image, which I am assuming is the one you started with in the first place.
No need to manually move backward and forward especially if it doesn't really do what you want anyway.
I am curious about your use of a count plus a suffix list. They only seem to serve to double check each other, nothing else. But that's not important here.
I'd like to discuss your use of SelectDocument. I know, you said it fails regardless of whether you use SelectDocument and because I can't actively test it I can only go by what I see and it should work just fine. Just to make sure let me run through the basics. There are two types of documents in scripts: TargetDocument (the document the script will act on) and ActiveDocument (the document currently active in the UI). SelectDocument 0 will set the TargetDocument to equal the ActiveDocument. SelectDocument 1 will move forward one document, SelectDocument -1 will move backwards. If you can't move backwards -1 or can't move forwards 1 then TargetDocument is not changed. If Strict is set to True an error will be thrown. If it's False it fails silently. If there are no images, or if all images but one are removed the TargetDocument is always set to the only open image without the need for SelectDocument. If multiple images are open, and the current targetdocument is closed the new target will be the last opened image in the list.
i'm assuming the workspace is not empty, simply because of how you're using SelectDocument but I will present both an empty and a full workspace in my scenarios.
So running your code through my head it looks like this.
1) You initialize the script by setting The TargetDocument to the currently Active Document. A bit redundant as they will be one and the same upon first run of the script unless you start with an empty workspace.
2) You grab all folders that match each index, expecting to find only one or at least only caring about the first one.
3) You grab all files that match the index, again only caring about the first one assuming there even could be other files matching the format you're looking for. Chances are there are not unless they have .*.* filenames before or after the pattern.
4) You commented out SelectDocument 1. Which if the workspace was empty would fail, if it wasn't would select the next available image in the list. So, depending on the state of the workspace when you ran the script would work like this.
If the workspace had a document open already
Removing the SelectDocument 1 would mean that all actions are executed on the current TargetDocument and never on the newly opened document.
If the workspace was empty
Removing the SelectDocument 1 would do nothing at all. SelectDocument1 would fail but TargetDocument would point to the newly opened image anyway because it needs a target and that's the only available image.
5) You do Select All
6) You do copy, which will fail if there is nothing to copy
7) You do file close
Again, at this point the script will change Targets if the current target was closed. Because you commented out SelectDocument this all depends on the state of the workspace.
With SelectDocument Commented out you get this
1) If workspace was empty, TargetDocument was the document that was just closed. It'll fail to create a new layer as there is no document open. Obviously not your problem.
2) If workspace had an open image already, Select Document was commented out so current you closed your original image, You are now working on the last opened image as the Target
With SelectDocument available you get thsi
1) If workspace was empty, SelectDocument Fails, TargetDocument doesn't change, you closed the current document, it'll fail to create a new layer as there is no document open. Again, obviously not the problem.
2) You had previously selected the next document in the list, TargetDocument pointed to that document, that document was closed, TargetDocument was reset to the last opened image. You run SelectDocument -1 if there is no -1, SelectDocument fails and TargetDocument remains last opened image.
8) You create a new raster layer on this new image
9) You do SelectAll on the new image
10) You paste into selection on new image
11) You increase the slice, select the next folder in the list and look for this new slice.
Does this match what you're seeing? Again just running through it in my head. SelectDocument Should work just fine. Though the easiest option would be to remove SelectDocument -1 and change SelectDocument 1 to SelectDocument 0.
SelectDocument 0 will set the newly opened image as the new target. Then when this image is closed, TargetDocument will once again become the last opened image, which I am assuming is the one you started with in the first place.
No need to manually move backward and forward especially if it doesn't really do what you want anyway.
https://levifiction.wordpress.com/
-
dangelic0
- Posts: 36
- Joined: Sat Oct 22, 2011 4:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Dell XPS 8920
- processor: Core i7-7700 4.2 GHx
- ram: 32GB
- Video Card: NVIDIA GeForce GTX 1060 6GB
- sound_card: Realtek High Definition Audio
- Hard_Drive_Capacity: 4 TB
- Monitor/Display Make & Model: LG Ultra HD
- Corel programs: PSP. VSP
Re: Please Help with "...command cannot execute in this cont
This is really great guidance. Based on your help I did clean up my usage of Active & Target documents. The script is still failing however.
I know it is difficult for you to help me troubleshoot without all the context. This is actually part of a two step process whereby I first create all the slice files from a series of timelapse exposures, then splice them back together in an order specified by user input. This script is the second part - the splicing.
It could be way simpler but for what I consider a bit of odd behavior in PSP. As you know, the developers made a functional choice about how to load a PSPimage that is mostly transparent. They chose to load it with the opaque bits centered, rather than preserving the position stored as part of the file. As such I have to open them one at a time, Copy All, and PasteInto to get the slice to position itself where it is positioned in the stored PSPimage.
Sigh.
I will proceed to troubleshoot based on the possibility that I have somehow bollixed up the slice creation (first) step
Thanks again _ I will let you know if/when I resolve this beast.
Dean
I know it is difficult for you to help me troubleshoot without all the context. This is actually part of a two step process whereby I first create all the slice files from a series of timelapse exposures, then splice them back together in an order specified by user input. This script is the second part - the splicing.
It could be way simpler but for what I consider a bit of odd behavior in PSP. As you know, the developers made a functional choice about how to load a PSPimage that is mostly transparent. They chose to load it with the opaque bits centered, rather than preserving the position stored as part of the file. As such I have to open them one at a time, Copy All, and PasteInto to get the slice to position itself where it is positioned in the stored PSPimage.
Sigh.
I will proceed to troubleshoot based on the possibility that I have somehow bollixed up the slice creation (first) step
Thanks again _ I will let you know if/when I resolve this beast.
Dean
-
LeviFiction
- Advisor
- Posts: 6831
- Joined: Thu Oct 02, 2008 1:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Alienware M17xR4
- processor: Intel Core i7-3630QM CPU - 2_40GH
- ram: 6 GB
- Video Card: NVIDIA GeForce GTX 660M
- sound_card: Sound Blaster Recon3Di
- Hard_Drive_Capacity: 500GB
- Corel programs: PSP: 8-2023
- Location: USA
Re: Please Help with "...command cannot execute in this cont
Yes, pasting into the center is one of those choices of PSP that makes sense but is annoying. Still, the method you're using of copy all and paste into seleciton is the best method of dealing with the pasting issue. It's simple, fast, clean, elegant.
https://levifiction.wordpress.com/
-
dangelic0
- Posts: 36
- Joined: Sat Oct 22, 2011 4:07 pm
- System_Drive: C
- 32bit or 64bit: 64 Bit
- motherboard: Dell XPS 8920
- processor: Core i7-7700 4.2 GHx
- ram: 32GB
- Video Card: NVIDIA GeForce GTX 1060 6GB
- sound_card: Realtek High Definition Audio
- Hard_Drive_Capacity: 4 TB
- Monitor/Display Make & Model: LG Ultra HD
- Corel programs: PSP. VSP
Re: Please Help with "...command cannot execute in this cont
This is now resolved, in a way that is quite dissatisfying for most programmers. I did refactor the code a bit, but in ways that should have no effect on the Doc navigation and/or PasteInto context. Yet after a reboot, the problem went away! Perhaps it was some stale state in the PSP or Python environment.
Anyway, I am back to the races.
Dean
Anyway, I am back to the races.
Dean
