AnsweredAssumed Answered

How to: Replace Auto-Increment start with variable; pStart = (variable) ??

Question asked by rdavis_CityofBiloxi on Aug 23, 2016
Latest reply on Sep 6, 2016 by rdavis_CityofBiloxi

Is it possible to replace the pStart in the code with a variable? In other words I have a value that I need to start from however the code is part of a model and the value may change every time the model is run so I cannot simply replace the "1" with whatever the value is(I have tried this and it works) because the model will be run on many datasets with different values. Here is my logic, I need to pass a value into "pStart =," what I have tried is to define a function and pass that as the pStart value. so that pStart = getfieldvalue then auto increment from this value. I need to replace the "1" with the value that my model has found,  here is my logic that does not work...


def getfieldvalue():
import arcpy
arcpy.ImportToolbox("Model Functions")
arcpy.GetFieldValue_mb("QueryTable_Statistics", "MAX_FEATURE_NUM", "String", "")

def autoIncrement(): 
global rec 
pStart = getfieldvalue(MAX_FEATURE_NUM) 
pInterval = 1
if (rec == 0):  
  rec = pStart  
  rec = rec + pInterval  
return rec 


Rough working model...