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...
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">getfieldvalue</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
arcpy<SPAN class="punctuation token">.</SPAN>ImportToolbox<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Model Functions"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>GetFieldValue_mb<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"QueryTable_Statistics"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"MAX_FEATURE_NUM"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"String"</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">""</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">return</SPAN>
rec<SPAN class="operator token">=</SPAN><SPAN class="number token">0</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">autoIncrement</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">global</SPAN> rec
pStart <SPAN class="operator token">=</SPAN> getfieldvalue<SPAN class="punctuation token">(</SPAN>MAX_FEATURE_NUM<SPAN class="punctuation token">)</SPAN>
pInterval <SPAN class="operator token">=</SPAN> <SPAN class="number token">1</SPAN>
<SPAN class="keyword token">if</SPAN> <SPAN class="punctuation token">(</SPAN>rec <SPAN class="operator token">==</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
rec <SPAN class="operator token">=</SPAN> pStart
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
rec <SPAN class="operator token">=</SPAN> rec <SPAN class="operator token">+</SPAN> pInterval
<SPAN class="keyword token">return</SPAN> rec
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
