<?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: Feature-Linked Annotation in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41779#M167</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;All,&lt;BR /&gt;&lt;BR /&gt;I have a script that works when the desired Feature Class is listed above Feature-Linked Annotations within ArcMap TOC.&amp;nbsp; But, the script does not work when the Feature Class is displayed below Feature-Linked Annotations.&amp;nbsp; What is the logic behind why this occurs?&lt;BR /&gt;&lt;BR /&gt;[ATTACH=CONFIG]27752[/ATTACH]&lt;BR /&gt;&lt;BR /&gt;[ATTACH=CONFIG]27753[/ATTACH]&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably the script is just getting the first layer in the map period.&amp;nbsp; It is the lazy, easy way to write a script.&amp;nbsp; Logic can be added to search the layer tree for a given layer name and get it at other levels, but it requires knowing the layer name in the code.&amp;nbsp; Or the selected layer could be used if the code is written to do that.&amp;nbsp; If layers are placed inside group layers, recursive layer searches need to be used (an additional aspect to the logic and set up).&amp;nbsp; Basically it is up to the programmers skill and experience to access the needed layer and to give or restrict the user's flexibility on where it is in the layer tree.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Sep 2013 19:03:01 GMT</pubDate>
    <dc:creator>RichardFairhurst</dc:creator>
    <dc:date>2013-09-25T19:03:01Z</dc:date>
    <item>
      <title>Feature-Linked Annotation</title>
      <link>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41778#M166</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a script that works when the desired Feature Class is listed above Feature-Linked Annotations within ArcMap TOC.&amp;nbsp; But, the script does not work when the Feature Class is displayed below Feature-Linked Annotations.&amp;nbsp; What is the logic behind why this occurs?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]27752[/ATTACH]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[ATTACH=CONFIG]27753[/ATTACH]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2013 16:26:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41778#M166</guid>
      <dc:creator>JacobDrvar</dc:creator>
      <dc:date>2013-09-25T16:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Feature-Linked Annotation</title>
      <link>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41779#M167</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;All,&lt;BR /&gt;&lt;BR /&gt;I have a script that works when the desired Feature Class is listed above Feature-Linked Annotations within ArcMap TOC.&amp;nbsp; But, the script does not work when the Feature Class is displayed below Feature-Linked Annotations.&amp;nbsp; What is the logic behind why this occurs?&lt;BR /&gt;&lt;BR /&gt;[ATTACH=CONFIG]27752[/ATTACH]&lt;BR /&gt;&lt;BR /&gt;[ATTACH=CONFIG]27753[/ATTACH]&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Probably the script is just getting the first layer in the map period.&amp;nbsp; It is the lazy, easy way to write a script.&amp;nbsp; Logic can be added to search the layer tree for a given layer name and get it at other levels, but it requires knowing the layer name in the code.&amp;nbsp; Or the selected layer could be used if the code is written to do that.&amp;nbsp; If layers are placed inside group layers, recursive layer searches need to be used (an additional aspect to the logic and set up).&amp;nbsp; Basically it is up to the programmers skill and experience to access the needed layer and to give or restrict the user's flexibility on where it is in the layer tree.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2013 19:03:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41779#M167</guid>
      <dc:creator>RichardFairhurst</dc:creator>
      <dc:date>2013-09-25T19:03:01Z</dc:date>
    </item>
    <item>
      <title>Re: Feature-Linked Annotation</title>
      <link>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41780#M168</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: jdrvar&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Probably the script is just getting the first layer in the map period.&amp;nbsp; It is the lazy, easy way to write a script.&amp;nbsp; Logic can be added to search the layer tree for a given layer name and get it at other levels, but it requires knowing the layer name in the code.&amp;nbsp; Or the selected layer could be used if the code is written to do that.&amp;nbsp; If layers are placed inside group layers, recursive layer searches need to be used (an additional aspect to the logic and set up).&amp;nbsp; Basically it is up to the programmers skill and experience to access the needed layer and to give or restrict the user's flexibility on where it is in the layer tree.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can place other Feature Classes above the Lot_Lines Feature Class and the script works.&amp;nbsp; The problem is moving the Feature-Linked Annotation Feature Classes above Lot_Lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;fc = arcpy.mapping.ListLayers(mxd, "Lot_Lines", df)[0]&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have the Lot_Lines Feature Class set to be called in the script.&amp;nbsp; I do not have any other Feature Classes set to be referenced.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Sep 2013 19:45:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41780#M168</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-09-25T19:45:50Z</dc:date>
    </item>
    <item>
      <title>Re: Feature-Linked Annotation</title>
      <link>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41781#M169</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Setting up a for loop solved the issue.&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Sep 2013 10:09:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41781#M169</guid>
      <dc:creator>JacobDrvar</dc:creator>
      <dc:date>2013-09-26T10:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Feature-Linked Annotation</title>
      <link>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41782#M170</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: jdrvar&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have other scripts that I would like to modify.&amp;nbsp; The scripts work when the Feature Class is the top Layer within the TOC.&amp;nbsp; Can you provide an example of a recursive layer search?&amp;nbsp; Thanks.&amp;nbsp; Previously I used &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for lyr in arcpy.mapping.ListLayers(lyr):.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Nov 2013 12:23:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41782#M170</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-11-01T12:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Feature-Linked Annotation</title>
      <link>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41783#M171</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: rfairhur24&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;I have other scripts that I would like to modify.&amp;nbsp; The scripts work when the Feature Class is the top Layer within the TOC.&amp;nbsp; Can you provide an example of a recursive layer search?&amp;nbsp; Thanks.&amp;nbsp; Previously I used &lt;BR /&gt;&lt;BR /&gt;for lyr in arcpy.mapping.ListLayers(lyr):.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;See &lt;/SPAN&gt;&lt;A href="http://forums.arcgis.com/threads/50037-obtain-index-of-layer-within-a-group-layer-in-python" rel="nofollow noopener noreferrer" target="_blank"&gt;this post&lt;/A&gt;&lt;SPAN&gt; for a way to do it one group layer deep.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

inMXD = r'c:\test.mxd'
outMXD = r'c:\test1.mxd'
rLayer = 'test3' #Name of reference layer
mLayer = 'test4' #Name of layer to be replaced and moved
lyrFile = arcpy.mapping.Layer(r'c:\Test4.lyr') #Layer file used to replace layer

mxd = arcpy.mapping.MapDocument(inMXD)
for df in arcpy.mapping.ListDataFrames(mxd):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #loop data frames
&amp;nbsp;&amp;nbsp;&amp;nbsp; for lyr in arcpy.mapping.ListLayers(mxd,"",df):&amp;nbsp;&amp;nbsp;&amp;nbsp; #loop layers
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if lyr.isGroupLayer == 1:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Is layer a group layer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for glyr in arcpy.mapping.ListLayers(lyr): #loop layer in group layer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if glyr != lyr:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Not Group Layer Name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if glyr.name.lower() == mLayer:&amp;nbsp;&amp;nbsp;&amp;nbsp; #Layer to be worked on&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Recursion involves setting up a second method that can call itself when it encounters each group layer, so it does not matter how deep the groups go.&amp;nbsp; Basically it would be something like this function (untested) which is called for every layer until you find the layer you want or you have no more layers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def layerInGroup(lyr, layerName):
&amp;nbsp; if lyr.isGroupLayer == 1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for glyr in arcpy.mapping.ListLayers(lyr): #loop layer in group layer
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if glyr != lyr:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; #Not Group Layer Name
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; resultlyr = layerInGroup(glyr, layerName)&amp;nbsp; # Recursively call the function for group in a group
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if resultlyr != None:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return resultlyr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # We found the layer deeper inside the group so return it and stop function
&amp;nbsp; elif lyr.name.lower() == layerName: # Not a group layer so test to see it is the one we want.
&amp;nbsp;&amp;nbsp;&amp;nbsp; return lyr&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # This is the layer we want so return it and stop function.
&amp;nbsp; return None&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # All tests failed to find layer we want so return None&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:36:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/feature-linked-annotation/m-p/41783#M171</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-10T21:36:58Z</dc:date>
    </item>
  </channel>
</rss>

