Trying to make multiple copies of my background layer

Moderator: Kathy_9

mangurian
Posts: 122
Joined: Wed Sep 01, 2010 4:54 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc 0K3CM7 A00
processor: Intel I7 11th Gen
ram: 64 Gig
Video Card: NVIDIA GeForce RTX 3060 [Display adapter]
Hard_Drive_Capacity: 3 T
Corel programs: VSP, PSP
Location: Connecticut USA

Trying to make multiple copies of my background layer

Post by mangurian »

I need help with using a "while" loop.
Looking for someone to answer a simple question about Python coding. I have some code with a "while" loop. The loop encompasses fewer instructions than I want. In other words, it loops back too early. I am a hobbiest and am just dabbling in Python to write scripts.
I want to loop on all of the code following the "while." The while loop only gets to the lines before the asterisks comment before it loops back:

Code: Select all

from PSPApp import *

def ScriptProperties():
    return {
        'Author': u'',
        'Copyright': u'',
        'Description': u'',
        'Host': u'P',
        'Host Version': u'24.00'
        }
    # Begin Loop ++++++++++++++++++++++++++++++++
numtimes = 1
while numtimes < 5: 
  numtimes += 1
  print numtimes  
  def Do(Environment):
    # EnableOptimizedScriptUndo
    App.Do( Environment, 'EnableOptimizedScriptUndo', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((24,0,0),1)
                }
            })
    # LayerDuplicate
    App.Do( Environment, 'LayerDuplicate', {
          'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((24,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': ((24,0,0),1)
                }
            })     

 


User avatar
fs999
Posts: 78
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: Trying to make multiple copies of my background layer

Post by fs999 »

Put the def do(Environment) over numtimes.

Code: Select all

from PSPApp import *

def ScriptProperties():
    return {
        'Author': u'',
        'Copyright': u'',
        'Description': u'',
        'Host': u'P',
        'Host Version': u'24.00'
        }
    # Begin Loop ++++++++++++++++++++++++++++++++
def Do(Environment):
  numtimes = 1
  while numtimes < 5: 
    numtimes += 1
    print numtimes  
    # EnableOptimizedScriptUndo
    App.Do( Environment, 'EnableOptimizedScriptUndo', {
            'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((24,0,0),1)
                }
            })
    # LayerDuplicate
    App.Do( Environment, 'LayerDuplicate', {
          'GeneralSettings': {
                'ExecutionMode': App.Constants.ExecutionMode.Default, 
                'AutoActionMode': App.Constants.AutoActionMode.Match, 
                'Version': ((24,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': ((24,0,0),1)
                }
            })     
mangurian
Posts: 122
Joined: Wed Sep 01, 2010 4:54 am
operating_system: Windows 10
System_Drive: C
32bit or 64bit: 64 Bit
motherboard: Dell Inc 0K3CM7 A00
processor: Intel I7 11th Gen
ram: 64 Gig
Video Card: NVIDIA GeForce RTX 3060 [Display adapter]
Hard_Drive_Capacity: 3 T
Corel programs: VSP, PSP
Location: Connecticut USA

Re: Trying to make multiple copies of my background layer

Post by mangurian »

fs999 - Thanks !! Brilliant. Being an 80 year old FORTRAN 77 progammer, all this indent and object stuff is a mystery I will have to overcome.