AnsweredAssumed Answered

Python, nested loops (?)

Question asked by mcollins999 on Jul 6, 2015
Latest reply on Jul 10, 2015 by mcollins999

I really have little or no aptitude for programming. I've created a model in model builder using fishnet (let's say 1 m cell width and height, 30 columns and 40 rows).


My problem is that I need to have 25x25 metre blocks numbered from 1 to 25 (see attachment).


The code I've managed to create just numbers them all 1 to 5. I was trying to get it to loop through 1 through 5 until the column count reached the end (30), then 6 through 10, etc. until 20 through 25. The code below is a python code block for calculating a field in model builder. I tried a bunch of things, but no go. I'm sure it's probably something simple but I can't wrap my head around it.


c = %Number of Columns%    # number of column blocks
count = 0
count2 = 0
def autoGrid():
   global y1
   global count
   global count2
   if (count <4): #main counter
      for i in range (1, 4):
         count += 1
         return count
   else: # step up counter
      y1 += 5
      count = 0
      count2 += 1 # counts the columns
      return y1