Scripting error question: JascApp.ArrangeInvalid

Moderator: Kathy_9

User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Scripting error question: JascApp.ArrangeInvalid

Post by gbotes »

I'm trying to record my second PaintShop Pro x8 script. Part of the script involves arranging layers. The script records perfectly, but on running I encounter the following error as soon as the script reaches the layer rearrange command:

------- Command Execution Failed -----------
Command Name: LayerArrange
Error Text: The arrange command is not valid in the current program state.
Traceback (most recent call last):
File "<string>", line 317, in Do
JascApp.ArrangeInvalid: Arrange command invalid in the current state
------- Command Execution Failed -----------
Command Name: RunScript
Error Text: The arrange command is not valid in the current program state.

Does anybody know why or have a workaround for this? I would assume that it should be possible to record and run a script that rearranges layers.
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
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: Scripting error question: JascApp.ArrangeInvalid

Post by LeviFiction »

Honestly, I'm not really sure what causes this. You'd think PSP wouldn't execute the next command until it was ready. But whenever this pops up it's like PSP is still completing the last action.

The only reliable way to deal with it that I've found, and this is probably ridiculous, is to force the script to wait 1 second just before executing the command that tends to fail.
https://levifiction.wordpress.com/
Cassel
Posts: 1587
Joined: Fri Oct 29, 2010 6:49 pm
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16Gb
Corel programs: PSP 8 (JASC) to PSP 2023
Location: Canada
Contact:

Re: Scripting error question: JascApp.ArrangeInvalid

Post by Cassel »

If it can't execute the arrange command, is it possible that the particular image/layer selection might prevent the command from being executed correctly?

Ex: trying to move a layer down 2 level, when that would be below a background layer? or trying to move more than one layer in a PSP version that can't handle that? or ending up with no layer selected (lost of focus after deleting something, often a vector) and obviously being unable to move a layer that is not active?
Cassel
https://creationcassel.com/store
Specializing in PSP specific products: scripts and tubes

https://scrapbookcampus.com
for beginner and seasoned scrappers and designers and other PSP users
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Scripting error question: JascApp.ArrangeInvalid

Post by gbotes »

Thanks for your responses. I appreciate it very much. I will try both suggestions.
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Scripting error question: JascApp.ArrangeInvalid

Post by gbotes »

By the way, Cassel, I've just bought your two PSP books on Amazon.com and am looking forward to start reading through them later this evening. I need to get up to speed with PSP quite quickly.
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Scripting error question: JascApp.ArrangeInvalid

Post by gbotes »

OK, I've tried inserting a waiting period in my script but the error remains despite a five second sleep. So, it seems it's not due to simultaneous command execution or a command still completing. Also, it doesn't seem to matter how I try to arrange the layers - one level or two levels up or down makes no difference.

I've emailed Corel support the question, and I'm hoping it's just a bug that need to be sorted out.
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
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: Scripting error question: JascApp.ArrangeInvalid

Post by LeviFiction »

Can we see the script?
https://levifiction.wordpress.com/
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Scripting error question: JascApp.ArrangeInvalid

Post by gbotes »

Sure can. It is related to the luminosity mask idea which I am still playing with. Once I've created the layers, I would like to arrange them in a sequence. Apart from this idea, though, I can see that in future I would like to use scripts to work with layers. This script is still rough - and made only using the script recorder.

Code: Select all

from PSPApp import *

def ScriptProperties():
    return {
        'Author': u'',
        'Copyright': u'',
        'Description': u'',
        'Host': u'PaintShop Pro',
        'Host Version': u'18.00'
        }

def Do(Environment):
    # EnableOptimizedScriptUndo
    App.Do( Environment, 'EnableOptimizedScriptUndo', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,2,[3],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,-1,[],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # MaskFromImage
    App.Do( Environment, 'MaskFromImage', {
            'CreateMaskFrom': App.Constants.CreateMaskFrom.Luminance, 
            'InvertMaskData': True, 
            'SourceImage': 0, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # DeleteLayer
    App.Do( Environment, 'DeleteLayer', {
            'Path': (0,1,[],False), 
            'MergeMask': True, 
            'WorkingMode': 1, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,1,[3],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # LayerArrange
    App.Do( Environment, 'LayerArrange', {
            'Path': (1,-1,[1],False), 
            'MoveAboveSibling': True, 
            'Path': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (1,-1,[3],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # LayerArrange
    App.Do( Environment, 'LayerArrange', {
            'Path': (1,1,[1],False), 
            'MoveAboveSibling': True, 
            'Path': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # Vector Selection Update
    App.Do( Environment, 'VectorSelectionUpdate', {
            'Path': (0,1,[],False), 
            'Type': App.Constants.ObjectSelection.Select, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Default, 
                'Version': ((18,0,0),1)
                }
            })

    # LayerMergeDown
    App.Do( Environment, 'LayerMergeDown', {
            'Path': None, 
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((18,0,0),1)
                }
            })

LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
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: Scripting error question: JascApp.ArrangeInvalid

Post by LeviFiction »

Yeah this fails for me to.

It seems to fail because no layer is actually selected for me. Whether or not that is the case for you I'm not sure. But it would make sense. Can't arrange a layer if no layer is actively selected. Can I assume this script was used alongside another script? I notice your error shows line 317 but there aren't 317 lines in this script, and it also reports it happened in the RunScript command.
https://levifiction.wordpress.com/
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Scripting error question: JascApp.ArrangeInvalid

Post by gbotes »

Thanks for looking at it, LeviFiction. The reason for the differences in line numbers is because I've made so many edits trying to understand the error, so the original error was posted from my first attempt but the code you're seeing is from later re-recording. It's not running alongside another script. But it was recorded by drag-n-drop rearrange of the layers. Records fine, but won't playback. Do you think the problem is the drag-n-drop? Is there another way to rearrange layers?
LeviFiction
Advisor
Posts: 6831
Joined: Thu Oct 02, 2008 1:07 pm
operating_system: Windows 10
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: Scripting error question: JascApp.ArrangeInvalid

Post by LeviFiction »

No, what I'm saying is that I continue to fall victim to my greatest enemy.

Jumping the gun. :P

There is indeed a bug with LayeArrange of some sort. I had to create an image with a layer setup that would work with the commands given in the script. Then step through it to make sure nothing ruined the state of the program. Stepping through I managed to prove to myself that it was indeed LayerArrange, and then realized I was being stupid all I had to do was record a script with a single layer arrange command than test that. So lots of silly mistakes on my part.

I have reported it to Corel.

EDIT: Just heard back they agree it needs to be fixed. Have no idea when it'll be fixed but at least they agree. xD
https://levifiction.wordpress.com/
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Scripting error question: JascApp.ArrangeInvalid

Post by gbotes »

Many thanks, LeviFiction! That makes me feel better.
User avatar
gbotes
Posts: 104
Joined: Wed Sep 30, 2015 11:31 am
operating_system: Windows 7 Professional
System_Drive: C
32bit or 64bit: 64 Bit
ram: 16GB
Hard_Drive_Capacity: 500Gb
Corel programs: Paint Shop Pro X8, Aftershot 2
Location: South Africa
Contact:

Re: Scripting error question: JascApp.ArrangeInvalid

Post by gbotes »

I seem to have found a workaround for this problem. Use the Layer Menu to rearrange layers during script recording rather than drag-n-drop which seems "iffy" with layers anyway. Needs further testing to be 100% sure, but seems to work.
afarkas
Posts: 38
Joined: Thu Oct 23, 2014 11:36 am
operating_system: Windows 7 Home Premium
System_Drive: C
32bit or 64bit: 64 Bit

Re: Scripting error question: JascApp.ArrangeInvalid

Post by afarkas »

Could you please explain how to insert waiting period into the script???
Thanks
LeviFiction wrote:Honestly, I'm not really sure what causes this. You'd think PSP wouldn't execute the next command until it was ready. But whenever this pops up it's like PSP is still completing the last action.

The only reliable way to deal with it that I've found, and this is probably ridiculous, is to force the script to wait 1 second just before executing the command that tends to fail.
afarkas
Posts: 38
Joined: Thu Oct 23, 2014 11:36 am
operating_system: Windows 7 Home Premium
System_Drive: C
32bit or 64bit: 64 Bit

Re: Scripting error question: JascApp.ArrangeInvalid

Post by afarkas »

Could you please explain how to insert waiting period into the script???
Thanks
gbotes wrote:OK, I've tried inserting a waiting period in my script but the error remains despite a five second sleep. So, it seems it's not due to simultaneous command execution or a command still completing. Also, it doesn't seem to matter how I try to arrange the layers - one level or two levels up or down makes no difference.

I've emailed Corel support the question, and I'm hoping it's just a bug that need to be sorted out.
Post Reply