<?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: How can I set the &amp;quot;Description&amp;quot; parameter of a layer with Python? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565231#M44243</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, thank you for your answer! Does anyone know if it's possible to define the parameter when saving a layer object to a file (like in the code below)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
[...]

layer = arcpy.MakeFeatureLayer_management(clippedFC, clippedFCLayer)
layer.description = "N/A"
arcpy.SaveToLayerFile_management(layer, clippedFCLayer, "RELATIVE")

[...]
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact, in my case, I'd like to set the description to "N/A" for all .lyr files in a given directory (either when creating the layer files or after they have been created) for packing them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Marc&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 00:21:29 GMT</pubDate>
    <dc:creator>MarcFasel</dc:creator>
    <dc:date>2021-12-12T00:21:29Z</dc:date>
    <item>
      <title>How can I set the &amp;quot;Description&amp;quot; parameter of a layer with Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565229#M44241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, I need to make a package of layers in a Python script. The "PackageLayer" tool required that the layers have a description in order to run, but the layers I have to pack are created and saved on disk just before the packaging. Thus, I can't set a description manually. There is a way to set it directly in Python? (or to avoid it as I don't need any description)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for your help&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Marc&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Apr 2011 11:50:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565229#M44241</guid>
      <dc:creator>MarcFasel</dc:creator>
      <dc:date>2011-04-18T11:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set the "Description" parameter of a layer with Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565230#M44242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You need to create a layer object and add the then pass a description text as a string to the layer property.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You can try something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.description = "some text"
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.save()

del mxd
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;See the layer properties here: &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s300000008000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00s300000008000000.htm&lt;/A&gt;&lt;SPAN&gt; for more information.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:21:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565230#M44242</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2021-12-12T00:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set the "Description" parameter of a layer with Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565231#M44243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, thank you for your answer! Does anyone know if it's possible to define the parameter when saving a layer object to a file (like in the code below)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
[...]

layer = arcpy.MakeFeatureLayer_management(clippedFC, clippedFCLayer)
layer.description = "N/A"
arcpy.SaveToLayerFile_management(layer, clippedFCLayer, "RELATIVE")

[...]
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In fact, in my case, I'd like to set the description to "N/A" for all .lyr files in a given directory (either when creating the layer files or after they have been created) for packing them.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Marc&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:21:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565231#M44243</guid>
      <dc:creator>MarcFasel</dc:creator>
      <dc:date>2021-12-12T00:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set the "Description" parameter of a layer with Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565232#M44244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You could manually create an empty MXD called 'Test.mxd'.&amp;nbsp; Then you can use python to add all the layer files from the directory, update the description, and delete MXD when you're finished.&amp;nbsp; Ex:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env
arcpy.env.overwriteOutput = True

env.workspace = "&amp;lt;lyr file workspace&amp;gt;"

mxd = arcpy.mapping.MapDocument(r"C:\temp\Test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "*")[0]

listFiles = arcpy.ListFiles("*.lyr")
for file in listFiles:
&amp;nbsp;&amp;nbsp;&amp;nbsp; addLayer = arcpy.mapping.Layer(file)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, addLayer)

arcpy.RefreshTOC()
arcpy.RefreshActiveView()

for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.description = "N/A"
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.saveACopy(str(lyr))

del mxd

os.remove(&amp;lt;'PathToMXD&amp;gt;')&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:21:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565232#M44244</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-12T00:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set the "Description" parameter of a layer with Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565233#M44245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm having some odd behavior with writing to the description of the layer in a mxd.&amp;nbsp; I've used the code below to write to the description:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Data\GISData\GDG\GrabDataPy\test.mxd")
for lyr in arcpy.mapping.ListLayers(mxd):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print
&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.name
&amp;nbsp;&amp;nbsp;&amp;nbsp; print lyr.description
&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.description = "some text"
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
mxd.save()
del mxd
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can see based on the code above print statement and the date/time on the mxd that when I run the above code the mxd is updated.&amp;nbsp; Since if I run this code a 2nd time, the print shows the new values, and the time changes on the file stamp of the mxd to when the code was last run.&amp;nbsp;&amp;nbsp;&amp;nbsp; However, when I open the mxd in ArcMap 10.0 sp3, the change to the description is not present.&amp;nbsp; It just has what was in it originally.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ideas??&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 00:21:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565233#M44245</guid>
      <dc:creator>FrankRoberts</dc:creator>
      <dc:date>2021-12-12T00:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set the "Description" parameter of a layer with Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565234#M44246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;On further testing, I have noticed that if I copy the mxd to a different machine, that I can see the changes. I just can't see the changes in ArcMap on the machine the python was ran from. Very strange.....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Nov 2011 18:33:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565234#M44246</guid>
      <dc:creator>FrankRoberts</dc:creator>
      <dc:date>2011-11-25T18:33:30Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set the "Description" parameter of a layer with Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565235#M44247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Did you try refreshing the TOC or Refreshing the Activeview before viewing the description?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 09:26:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565235#M44247</guid>
      <dc:creator>AndrewChapkowski</dc:creator>
      <dc:date>2011-11-28T09:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: How can I set the "Description" parameter of a layer with Python?</title>
      <link>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565236#M44248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Andrew, thank for chiming back in.&amp;nbsp; I'm running the python code from the Command Prompt window (aka dos prompt).&amp;nbsp; I have rebooted my machine and now it seems to see the changes after running the script.&amp;nbsp; Not sure what was buggered up...&amp;nbsp; I did swap in the code per your recommendation and ran it with it and without it and it didn't seem to make a difference.&amp;nbsp; At least now it is working as it should.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Nov 2011 18:16:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-can-i-set-the-amp-quot-description-amp-quot/m-p/565236#M44248</guid>
      <dc:creator>FrankRoberts</dc:creator>
      <dc:date>2011-11-28T18:16:51Z</dc:date>
    </item>
  </channel>
</rss>

