<?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: Python CIM Accessing Label Properties in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515544#M40450</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It may be a bug in the CIM access. The one time I tried it, and used CIM access to change label properties for a &lt;A href="https://pro.arcgis.com/en/pro-app/help/data/query-layers/what-is-a-query-layer-.htm"&gt;Query Layer&lt;/A&gt;, I discovered it resulted in the loss of the datasource as soon as I set the CIM definition using &lt;STRONG&gt;lyr.setDefinition&lt;/STRONG&gt;. This made CIM access unusable for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my particular case, it was possible to workaround the issue by saving the layer to disk first as &lt;STRONG&gt;*.lyrx&lt;/STRONG&gt; layer file using &lt;STRONG&gt;lyr.saveACopy&lt;/STRONG&gt;, then do a json edit using the ordinary Python &lt;STRONG&gt;json.load&lt;/STRONG&gt; and &lt;STRONG&gt;json.dump&lt;/STRONG&gt; methods, and finally reload the layer in the project. This requires good knowledge and understanding of the structure of the CIM though, and how it translates to the dictionary structure that &lt;STRONG&gt;json.load&lt;/STRONG&gt; creates. It took me a couple of rounds and thought to get it right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, ESRI definitely, and probably rightly so, discourages direct json editing of layer files, but it can be done if you are careful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 28 Oct 2020 20:57:51 GMT</pubDate>
    <dc:creator>MarcoBoeringa</dc:creator>
    <dc:date>2020-10-28T20:57:51Z</dc:date>
    <item>
      <title>Python CIM Accessing Label Properties</title>
      <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515541#M40447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I am trying to adjust the labelling properties of a point layer through python by accessing the CIM in a script tool. When I run the tool, the properties are applied to the layer, however they do not draw. The labelling properties dialogue box reflects my changes, however the labels are not drawing to reflect the changes. Code below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am attempting to change the rotation of a label by assigning the rotationField to a field in my attribute table called 'Bearing'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;lyr = m.listLayers(out_pointslayer + &lt;SPAN style="color: #6a8759;"&gt;"_Map"&lt;/SPAN&gt;)[&lt;SPAN style="color: #6897bb;"&gt;0&lt;/SPAN&gt;]
ldef=lyr.getDefinition(&lt;SPAN style="color: #6a8759;"&gt;'V2'&lt;/SPAN&gt;)
&lt;SPAN style="color: #cc7832;"&gt;for &lt;/SPAN&gt;eachclass &lt;SPAN style="color: #cc7832;"&gt;in &lt;/SPAN&gt;ldef.labelClasses:
    &lt;SPAN style="color: #cc7832;"&gt;if &lt;/SPAN&gt;eachclass.name == &lt;SPAN style="color: #6a8759;"&gt;'Class 1'&lt;/SPAN&gt;:
        lblclass = eachclass

lblclass.maplexLabelPlacementProperties.rotationProperties.rotationField = &lt;SPAN style="color: #6a8759;"&gt;'Bearing'&lt;/SPAN&gt;&lt;SPAN style="color: #6897bb;"&gt;
&lt;/SPAN&gt;lyr.setDefinition(ldef)

lyr.showLabels = &lt;SPAN style="color: #cc7832;"&gt;True
&lt;/SPAN&gt;&lt;SPAN style="color: #cc7832;"&gt;
&lt;/SPAN&gt;aprx.save()&lt;/PRE&gt;&lt;P&gt;After running this code in a script tool, the labelling properties seem to reflect the changes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/512018_Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;However the rotation does not get applied in the rendering of the labels, however it works when I@@ do it manually.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji jive-image image-2 j-img-original" src="https://community.esri.com/legacyfs/online/512019_Capture2.PNG" /&gt;&lt;/P&gt;&lt;P&gt;Any Help would be much appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:31:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515541#M40447</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T22:31:08Z</dc:date>
    </item>
    <item>
      <title>Re: Python CIM Accessing Label Properties</title>
      <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515542#M40448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It may be the indent missing after your for loop, dunno if the class has to be set to visible also?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just my random musings with little experience of arcpy label classes or Pro.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2020 20:34:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515542#M40448</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-10-28T20:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python CIM Accessing Label Properties</title>
      <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515543#M40449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Didn't work unfortunately, Thank you for the response though!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2020 20:46:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515543#M40449</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-10-28T20:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Python CIM Accessing Label Properties</title>
      <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515544#M40450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It may be a bug in the CIM access. The one time I tried it, and used CIM access to change label properties for a &lt;A href="https://pro.arcgis.com/en/pro-app/help/data/query-layers/what-is-a-query-layer-.htm"&gt;Query Layer&lt;/A&gt;, I discovered it resulted in the loss of the datasource as soon as I set the CIM definition using &lt;STRONG&gt;lyr.setDefinition&lt;/STRONG&gt;. This made CIM access unusable for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my particular case, it was possible to workaround the issue by saving the layer to disk first as &lt;STRONG&gt;*.lyrx&lt;/STRONG&gt; layer file using &lt;STRONG&gt;lyr.saveACopy&lt;/STRONG&gt;, then do a json edit using the ordinary Python &lt;STRONG&gt;json.load&lt;/STRONG&gt; and &lt;STRONG&gt;json.dump&lt;/STRONG&gt; methods, and finally reload the layer in the project. This requires good knowledge and understanding of the structure of the CIM though, and how it translates to the dictionary structure that &lt;STRONG&gt;json.load&lt;/STRONG&gt; creates. It took me a couple of rounds and thought to get it right.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, ESRI definitely, and probably rightly so, discourages direct json editing of layer files, but it can be done if you are careful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 28 Oct 2020 20:57:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515544#M40450</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2020-10-28T20:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Python CIM Accessing Label Properties</title>
      <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515545#M40451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;For sure, I would like to keep editing the actual json as a last resort but it might be the only option right now, Thank you.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 13:00:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515545#M40451</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-10-29T13:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Python CIM Accessing Label Properties</title>
      <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515546#M40452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Solved: Need to add this line of code in.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV&gt;lblclass.maplexLabelPlacementProperties.rotationProperties.enable = &lt;SPAN&gt;True&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 15:22:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515546#M40452</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-10-29T15:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Python CIM Accessing Label Properties</title>
      <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515547#M40453</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice you got it to work. Haven't had a look at the rotation properties myself, so missed the obvious.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 18:34:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515547#M40453</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2020-10-29T18:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python CIM Accessing Label Properties</title>
      <link>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515548#M40454</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is misleading in the GUI is that you don't have to enable it explicitly, just setting it appears to enable it as well.&amp;nbsp; Convenient for the end-user , but confusing for the developer who doesn't expect a two-step process.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 19:15:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-cim-accessing-label-properties/m-p/515548#M40454</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2020-10-29T19:15:37Z</dc:date>
    </item>
  </channel>
</rss>

