I really don't know how to phrase the question actually. I started by using a calculate field management, except that my codeblock started to run on for hundreds of lines and was hard to read and write in (in notepad++ you see solid orange code), but it worked. Specifically, I could create layers using MakeFeatureLayer that where isolated to the codeblock and never appeared in the table of contents of ArcGIS.
Because I will be handing my code down to others to interpret and modify as suits them I decided to try replacing the calculate field with an update cursor. Currently it is not able to run the MakeFeatureLayer within my For loop that I am using to implement my update cursor and it raises this error code:
MakeFeatureLayer raise e ExecuteError: ERROR 999999: Error executing function. Cannot acquire a lock. Cannot acquire a lock. Failed to execute (MakeFeatureLayer).
Even if I do get it to work though, I do not know if it will try to create a layer outside of the loop over each iteration. (perhaps I could try deleting the layer in each loop after I am finished using it).
Here is a code snipet. Any ideas how to get MakeFeatureLayer working?
<SPAN class="comment token"># Set local variables</SPAN>
inTable <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Murray Sp2"</SPAN>
<SPAN class="keyword token">def</SPAN> <SPAN class="token function">Strike</SPAN><SPAN class="punctuation token">(</SPAN>shape<SPAN class="punctuation token">,</SPAN> fid<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN>
<SPAN class="keyword token">if</SPAN> length <SPAN class="operator token">>=</SPAN> <SPAN class="number token">183</SPAN> <SPAN class="operator token">and</SPAN> length <SPAN class="operator token"><=</SPAN> <SPAN class="number token">185</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN>
<SPAN class="comment token"># I next make the shapelyr feature layer out of my current intable(Murray Sp2), but only select the current object being</SPAN>
<SPAN class="comment token">#calculated by using the where statement to select only the objct with the current FID</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>inTable<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'shapelyr'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'"FID" ='</SPAN><SPAN class="operator token">+</SPAN>str<SPAN class="punctuation token">(</SPAN>fid<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># I then make the PairedCheck6 feature layer out of my current intable(Zarza data), but excluding the current object being</SPAN>
<SPAN class="comment token">#calculated by using the where statement to select only objects that do not match the current FID. This layer will be used </SPAN>
<SPAN class="comment token">#to select the matching dip symble that belongs with the strike symbol for which the azimuth is being calculated</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>MakeFeatureLayer_management<SPAN class="punctuation token">(</SPAN>inTable<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'PairedCheck6'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'"FID" <>'</SPAN><SPAN class="operator token">+</SPAN>str<SPAN class="punctuation token">(</SPAN>fid<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="punctuation token">.</SPAN>
cursor <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN class="punctuation token">.</SPAN>UpdateCursor<SPAN class="punctuation token">(</SPAN>inTable<SPAN class="punctuation token">,</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">'Shape@'</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="string token">'FID'</SPAN><SPAN class="punctuation token">,</SPAN> fieldName<SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">for</SPAN> row <SPAN class="keyword token">in</SPAN> cursor<SPAN class="punctuation token">:</SPAN>
row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">=</SPAN> Strike<SPAN class="punctuation token">(</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">,</SPAN> row<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
cursor<SPAN class="punctuation token">.</SPAN>updateRow<SPAN class="punctuation token">(</SPAN>row<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>