Endless loop with SelectPreviousLayer

Moderator: Kathy_9

Post Reply
User avatar
fs999
Posts: 46
Joined: Thu Jul 21, 2011 9:55 pm
operating_system: Windows 10
System_Drive: Z
32bit or 64bit: 64 Bit
motherboard: Intel
processor: i7 860
ram: 32GB
Video Card: NVIDIA GeForce GTX 730
sound_card: Samsung HDMI
Hard_Drive_Capacity: 28 TB
Monitor/Display Make & Model: Philips 24P4 & Samsung UE46M6050
Corel programs: PaintShop 2020 Ultimate

Endless loop with SelectPreviousLayer

Post by fs999 »

Hello,

There seems to be a endless loop error with the SelectPreviousLayer if a selection has been saved in the Alpha Chanel of the image, the function always returns True.
I use this part of code to go to the bottom layer and iterate every layer up.
I have tried with SelectNextLayer there is no such a problem.
And if no selection is saved in the Alpha Chanel, the function works well.

Code: Select all

      
    FoundLayer = True 
    while FoundLayer == True: 
        FoundLayer = App.Do( Environment, 'SelectPreviousLayer', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Silent, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((19,0,0),1)
                }
            })
LeviFiction
Advisor
Posts: 5985
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, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Endless loop with SelectPreviousLayer

Post by LeviFiction »

Interesting, shall have to look into that. i wonder if it happens in earlier versions of PSP or if it's new to 2020.

You might find this helpful, this comes from the Scripting Guide provided by Corel. It's a fast way to quickly select the bottom-most layer in a single command

Code: Select all

    # start by selecting the bottommost layer in the image.
    App.Do( Environment, 'SelectLayer', { 'Path': (9999,-9999, [], False ) } )
It leaves out the GeneralSettings as they don't really do anything with commands like this so it's an easy space saver to leave it out.
User avatar
fs999
Posts: 46
Joined: Thu Jul 21, 2011 9:55 pm
operating_system: Windows 10
System_Drive: Z
32bit or 64bit: 64 Bit
motherboard: Intel
processor: i7 860
ram: 32GB
Video Card: NVIDIA GeForce GTX 730
sound_card: Samsung HDMI
Hard_Drive_Capacity: 28 TB
Monitor/Display Make & Model: Philips 24P4 & Samsung UE46M6050
Corel programs: PaintShop 2020 Ultimate

Re: Endless loop with SelectPreviousLayer

Post by fs999 »

It is also in PSP 2019.

I will try your solution.

Thank you !
User avatar
fs999
Posts: 46
Joined: Thu Jul 21, 2011 9:55 pm
operating_system: Windows 10
System_Drive: Z
32bit or 64bit: 64 Bit
motherboard: Intel
processor: i7 860
ram: 32GB
Video Card: NVIDIA GeForce GTX 730
sound_card: Samsung HDMI
Hard_Drive_Capacity: 28 TB
Monitor/Display Make & Model: Philips 24P4 & Samsung UE46M6050
Corel programs: PaintShop 2020 Ultimate

Re: Endless loop with SelectPreviousLayer

Post by fs999 »

This SelectLayer doesn't work. I've tried it last year, that's why I made that loop.

I have added a message box asking if I used the alpha chanel and not iterating when true...
LeviFiction
Advisor
Posts: 5985
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, 9, X, XI, X2, X8,X9, 2018, 2019
Location: USA

Re: Endless loop with SelectPreviousLayer

Post by LeviFiction »

Interesting.

First I have verified the bug you reference, i added a break condition so it wouldn't loop forever, but I can verify it and I will report it to Corel.

EDIT: I'm updating my solution to be even easier.

One option you can try is after selecting the layer, grab its absolute layer path. If the layer path is (0,0, [], False) then you're on the bottom layer, and can just break the loop.

Code: Select all

    LayerExists = True
    while LayerExists:
        LayerExists = App.Do( Environment, 'SelectPreviousLayer', {})
        p = App.Do( Environment, 'ReturnLayerProperties', {})['Path']
        if p == (0,0,[],False): #Bottom layer path
            break 
Second, I'm honestly suprised the SelectLayer option I gave you didn't work. It works in all of my tests, I can't seem to find a way to break it.
User avatar
fs999
Posts: 46
Joined: Thu Jul 21, 2011 9:55 pm
operating_system: Windows 10
System_Drive: Z
32bit or 64bit: 64 Bit
motherboard: Intel
processor: i7 860
ram: 32GB
Video Card: NVIDIA GeForce GTX 730
sound_card: Samsung HDMI
Hard_Drive_Capacity: 28 TB
Monitor/Display Make & Model: Philips 24P4 & Samsung UE46M6050
Corel programs: PaintShop 2020 Ultimate

Re: Endless loop with SelectPreviousLayer

Post by fs999 »

Yes ! That works !

Thank you very much !
Post Reply