Hi
I'm attempting to roll through a bunch of edits per user input on a point feature. Unfortunately, i get this script to work on non-geometric network features with the arcpy.da editing functions. I'm attempting to use the arcpy.insertCursor here because of that geometric network participation on this point feature. I keep getting this error:
On Line 65 - ValueError: Row: Invalid input value for SetValue
Code is as follows:
<SPAN class="keyword token">import</SPAN> arcpy<SPAN class="punctuation token">,</SPAN> time<SPAN class="punctuation token">,</SPAN> datetime<SPAN class="punctuation token">,</SPAN> os
<SPAN class="comment token">#Set variables</SPAN>
FilePath <SPAN class="operator token">=</SPAN> <SPAN class="string token">"E:\\Program Files\\Consumers Energy\\SIMS\\MassEdit\\"</SPAN>
SDEUser <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>FilePath <SPAN class="operator token">+</SPAN> <SPAN class="string token">"Dev_GasDist_PrimeSDE.sde"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#SDE connection</SPAN>
VsdeFolder <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>FilePath <SPAN class="operator token">+</SPAN> <SPAN class="string token">"SDExnnections"</SPAN><SPAN class="punctuation token">)</SPAN>
VersionList <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token">#mutable list</SPAN>
VersionCount <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> <SPAN class="comment token">#var for amount of versions on mappingdefault</SPAN>
MX <SPAN class="operator token">=</SPAN> <SPAN class="number token">5000</SPAN> <SPAN class="comment token">#maximum allowed edits</SPAN>
UserInput <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>input<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Edits Needed (Divided per versions in mapping default): '</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#total edits input by user</SPAN>
TotalEdits <SPAN class="operator token">=</SPAN> UserInput <SPAN class="keyword token">if</SPAN> UserInput <SPAN class="operator token"><</SPAN> <SPAN class="number token">5000</SPAN> <SPAN class="keyword token">else</SPAN> MX <SPAN class="comment token">#var for edits</SPAN>
fieldsPoly <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'Shape@'</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#fields to fill in for edits</SPAN>
fieldsPoint <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">'SHAPE@X'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'SHAPE@Y'</SPAN><SPAN class="punctuation token">)</SPAN>
counterV <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN> <SPAN class="comment token">#version counter</SPAN>
counterR <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">makeCurbValve</SPAN><SPAN class="punctuation token">(</SPAN>MoveBy2<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
pCurbValve <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Point<SPAN class="punctuation token">(</SPAN><SPAN class="number token">3289001.0213</SPAN> <SPAN class="operator token">+</SPAN> MoveBy2<SPAN class="punctuation token">,</SPAN><SPAN class="number token">4376077.827</SPAN> <SPAN class="operator token">+</SPAN> MoveBy2<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">return</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>PointGeometry<SPAN class="punctuation token">(</SPAN>pCurbValve<SPAN class="punctuation token">)</SPAN>
For ChildVersionName <SPAN class="keyword token">in</SPAN> VersionList<SPAN class="punctuation token">:</SPAN>
counterV <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>counterV <SPAN class="operator token">+</SPAN> <SPAN class="punctuation token">(</SPAN>int<SPAN class="punctuation token">(</SPAN>VersionCount<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="number token">8500</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
EditVersion <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>CreateDatabaseConnection_management<SPAN class="punctuation token">(</SPAN><SPAN class="string token">'''''''</SPAN>'<SPAN class="punctuation token">)</SPAN>
T_SDEConnection <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>str<SPAN class="punctuation token">(</SPAN>EditVersion<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
fc <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">(</SPAN>T_SDEConnection <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\GASDIST.P_CurbValve"</SPAN><SPAN class="punctuation token">)</SPAN>
workspace <SPAN class="operator token">=</SPAN> os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>dirname<SPAN class="punctuation token">(</SPAN>fc<SPAN class="punctuation token">)</SPAN>
Edit <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>Editor<SPAN class="punctuation token">(</SPAN>workspace<SPAN class="punctuation token">)</SPAN>
Edit<SPAN class="punctuation token">.</SPAN>startEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">False</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
Edit<SPAN class="punctuation token">.</SPAN>startOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
cursorInsert <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>InsertCursor<SPAN class="punctuation token">(</SPAN>T_SDEConnection <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\\GASDIST.P_CurbValve"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> ChildVersionCount <SPAN class="keyword token">in</SPAN> range<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">,</SPAN> int<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">(</SPAN>TotalEdits<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">/</SPAN>VersionCount<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
counterR <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>counterR <SPAN class="operator token">+</SPAN> <SPAN class="number token">5</SPAN><SPAN class="punctuation token">)</SPAN>
start <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>time<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
CoordXY <SPAN class="operator token">=</SPAN> makeCurbValve<SPAN class="punctuation token">(</SPAN>counterR <SPAN class="operator token">+</SPAN> counterV<SPAN class="punctuation token">)</SPAN>
InsertNewRow <SPAN class="operator token">=</SPAN> cursorInsert<SPAN class="punctuation token">.</SPAN>newRow<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
InsertNewRow<SPAN class="punctuation token">.</SPAN>setValue<SPAN class="punctuation token">(</SPAN>fieldPoint<SPAN class="punctuation token">,</SPAN>CoordXY<SPAN class="punctuation token">)</SPAN>
cursorInsert<SPAN class="punctuation token">.</SPAN>insertRow<SPAN class="punctuation token">(</SPAN>InsertNewRow<SPAN class="punctuation token">)</SPAN>
end <SPAN class="operator token">=</SPAN> time<SPAN class="punctuation token">.</SPAN>time<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
Edit<SPAN class="punctuation token">.</SPAN>stopOperation<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
Edit<SPAN class="punctuation token">.</SPAN>stopEditing<SPAN class="punctuation token">(</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN><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></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><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>