<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Turn fields off by script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250030#M19283</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your reply,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I understand the general idea you're getting at there.&amp;nbsp; My code left off with a &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;field_info&lt;/SPAN&gt;&lt;SPAN&gt; object needing to be assigned to a Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I went ahead and did :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.MakeFeatureLayer_management(LayerNeedsFieldsTurnedOff,"temp_layer","","",field_info)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This resulted in a feature layer that does have the fields turned off as desired, though symbology and labeling got messed up (that can be fixed layer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With the fields fixed in the "temp_layer", I used the arcpy.mapping.UpdateLayer like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;tempLayer = arcpy.mapping.Layer("temp_layer")
arcpy.mapping.UpdateLayer(df,arcpy.mapping.Layer(LayerNeedsFieldsTurnedOff, tempLayer)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, it looks like the UpdateLayer method doesn't carry over the field information to the original layer.&amp;nbsp; The only method I've seen so far that even accepts the FieldInfo() object as an argument seems to be MakeFeatureLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suspect what I'm looking to do may not be possible with existing arcpy, as the layer docs show .fieldInfo as being a 'read only' property.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000063000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000063000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have any sample code, I'd love to take a look at it though!&amp;nbsp; Probably won't be able to tinker with it until next week Monday though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 12:25:59 GMT</pubDate>
    <dc:creator>MattEiben</dc:creator>
    <dc:date>2021-12-11T12:25:59Z</dc:date>
    <item>
      <title>Turn fields off by script</title>
      <link>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250028#M19281</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've been beating my head against a wall for a full workday trying to figure this one out.&amp;nbsp; What I want to accomplish is to turn a number of fields off in a feature layer.&amp;nbsp; There is a method using the fieldInfo() method, but that only seems to work when creating a NEW feature layer.&amp;nbsp; I want to apply the turned off fields to the EXISTING layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code example below&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&amp;nbsp; df = arcpy.mapping.ListDataFrames(mxd, "*")[0]&amp;nbsp; LayerNeedsFieldsTurnedOff = arcpy.mapping.ListLayers(mxd, "Layer Name", df)[0]&amp;nbsp; desiredFields = ["LAST","FIRST","CITY","ZIP"]&amp;nbsp; # This makes the field_info object that can then be applied to a layer field_info = arcpy.Describe(LayerNeedsFieldsTurnedOff).fieldInfo for index in xrange(0, field_info.count): &amp;nbsp;&amp;nbsp;&amp;nbsp; if field_info.getfieldname(index) not in engineFields: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field_info.setvisible(index,"HIDDEN")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This is where I'm not sure what to do, all the examples show making an new layer like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.MakeFeatureLayer_management(LayerNeedsFieldsTurnedOff,"temp_layer","","",field_info)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This however set's me down a rabbit hole I really don't want to go down.&amp;nbsp; (duplicate layers, symbology, labeling, etc...) Is there a way to apply the field visibilities back to the original layer and not a new one?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Dec 2013 20:45:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250028#M19281</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2013-12-06T20:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Turn fields off by script</title>
      <link>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250029#M19282</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Interesting...I haven't tried this but can you use the UpdateLayer command?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I mean is, maybe it is possible to create a new layer obj (as you already know how to do) from your map feature layer, then go through similar steps as you seem to already have a handle on with your posted code, then 'stamp' your map layer object (using UpdateLayer) with your new layer object with the fieldInfo object associated with it (which has the fields turned on/off as you wish).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does that make sense? - you already have most of the code and I am assuming you successfully defined the new layer field visibility?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When you ListLayers and get a handle on the appropriate layer within your mxd (or lyr), supposedly you can switch layer objects.&amp;nbsp; It's been a little while since I've tried it but think it works, see the syntax and webhelp ref below.&amp;nbsp; There are good bits of sample code at the webhelp or I can dig up some of my code later if you still need it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope you get it going--&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UpdateLayer (data_frame, update_layer, source_layer, {symbology_only})&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;UpdateLayer (arcpy.mapping)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Desktop » Geoprocessing » ArcPy » Mapping module » Functions&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000003p000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000003p000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;EDIT:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;By the way, there is a similar post I made &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/68702-Cut-polygons-with-grid?#10"&gt;here&lt;/A&gt;&lt;SPAN&gt; using the fieldInfo object to set the ratio policy of a 'new' feature layer to subsequently use in Intersect processing.&amp;nbsp; I'd like to test (when I get to my other computer) whether I can extend the code posted there to 'grab' the layers from a map doc and similarly set the visibility on the fieldInfo and combine that with the Intersect (or any other overlay processing) and use the output layer to update an existing lyr in the map doc.&amp;nbsp; It would not be a stretch...let me know how yours works.&amp;nbsp; If I remember, I will later post the test I just mentioned.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Dec 2013 21:30:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250029#M19282</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-12-06T21:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Turn fields off by script</title>
      <link>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250030#M19283</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for your reply,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think I understand the general idea you're getting at there.&amp;nbsp; My code left off with a &lt;/SPAN&gt;&lt;SPAN style="text-decoration:underline;"&gt;field_info&lt;/SPAN&gt;&lt;SPAN&gt; object needing to be assigned to a Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I went ahead and did :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.MakeFeatureLayer_management(LayerNeedsFieldsTurnedOff,"temp_layer","","",field_info)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This resulted in a feature layer that does have the fields turned off as desired, though symbology and labeling got messed up (that can be fixed layer).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;With the fields fixed in the "temp_layer", I used the arcpy.mapping.UpdateLayer like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;tempLayer = arcpy.mapping.Layer("temp_layer")
arcpy.mapping.UpdateLayer(df,arcpy.mapping.Layer(LayerNeedsFieldsTurnedOff, tempLayer)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, it looks like the UpdateLayer method doesn't carry over the field information to the original layer.&amp;nbsp; The only method I've seen so far that even accepts the FieldInfo() object as an argument seems to be MakeFeatureLayer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I suspect what I'm looking to do may not be possible with existing arcpy, as the layer docs show .fieldInfo as being a 'read only' property.&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000063000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000063000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have any sample code, I'd love to take a look at it though!&amp;nbsp; Probably won't be able to tinker with it until next week Monday though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:25:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250030#M19283</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2021-12-11T12:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Turn fields off by script</title>
      <link>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250031#M19284</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN&gt;I wasn't entirely satisfied with the following code, but seems to do the trick - it comes with the caveat that you have to 'manually' code other things like labeling.&amp;nbsp; Maybe I am missing something but found that since I 'stamped' what seems to be a new layer from the MFL execution to include the field_info obj, it dropped my labeling.&amp;nbsp; It also wrote 'temp_layer' in the Description property.&amp;nbsp; But my layer is written with at least the correct field_info settings.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;overwriteOutput &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;True&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;env&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;addOutputsToMap &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;
mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;'your path to target mxd'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
df &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'*'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
LayerNeedsFieldsTurnedOff &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'your target layer name'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; df&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&amp;nbsp; 

&lt;SPAN class="comment token"&gt;# fill in your desired fields to remain visible &lt;/SPAN&gt;
desiredFields &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'fieldname0'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'fieldname1'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'fieldname2'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'etc'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&amp;nbsp; 
field_info &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Describe&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;LayerNeedsFieldsTurnedOff&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fieldInfo 
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; i &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; range&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;field_info&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;count&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; field_info&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;getfieldname&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; desiredFields&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; field_info&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;setvisible&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;i&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'HIDDEN'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MakeFeatureLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;LayerNeedsFieldsTurnedOff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'temp_layer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;''&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;''&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; field_info&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp; 
refLyr &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Layer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'temp_layer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp; 

&lt;SPAN class="comment token"&gt;# rename the ref layer the same as your target layer &lt;/SPAN&gt;
refLyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'your target layer name'&lt;/SPAN&gt;&amp;nbsp; 
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ApplySymbologyFromLayer_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;refLyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; LayerNeedsFieldsTurnedOff&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; 
arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;UpdateLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;df&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; LayerNeedsFieldsTurnedOff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; refLyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token boolean"&gt;False&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp; 
mxd&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;save&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&amp;nbsp; 

&lt;SPAN class="comment token"&gt;# clean up&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Exists&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'temp_layer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'\'temp_layer\' still in memory...deleting now...'&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Delete_management&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;'temp_layer'&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'deleting obj refs...'&lt;/SPAN&gt; 
&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;LayerNeedsFieldsTurnedOff&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; refLyr 
&lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;'done.'&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just a further note - seems you could 'mine' properties from a lyr library or another mxd (or such library) to more easily 'reapply' these properties, for instance, like labeling.&lt;/P&gt;&lt;P&gt;-Wayne&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:26:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250031#M19284</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2021-12-11T12:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Turn fields off by script</title>
      <link>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250032#M19285</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This is exactly what I was looking for!&amp;nbsp; I was getting pretty close, but that neatly ties it up.&amp;nbsp; Thanks for the code sample.&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp; Hopefully, ESRI makes fieldInfo() a write attribute in the future, that would make this a little less roundabout.&amp;nbsp; Thanks again!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Matt&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2013 18:20:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250032#M19285</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2013-12-09T18:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Turn fields off by script</title>
      <link>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250033#M19286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, I wholeheartedly agree...good catch.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you will, go ahead and mark this thread answered so that it is closed.&amp;nbsp; You are new to the forum, so if you don't know how, just fiddle with the button controls over to the right of the posts.&amp;nbsp; You have to be logged in; you can only 'checkmark' one post, next to the one you feel represents the best answer (or, if you feel so inclined, do not mark an answer)...toggle up for points next to any posts you want to award.&amp;nbsp; That's it, oh and welcome to the forums - good start!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Enjoy,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Wayne&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Dec 2013 19:04:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/turn-fields-off-by-script/m-p/250033#M19286</guid>
      <dc:creator>T__WayneWhitley</dc:creator>
      <dc:date>2013-12-09T19:04:01Z</dc:date>
    </item>
  </channel>
</rss>

