<?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: Get layer of selected object in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298313#M7734</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good point.&amp;nbsp; Something else to figure out how to do.&amp;nbsp; I appreciate your suggestions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 02 Dec 2011 20:36:25 GMT</pubDate>
    <dc:creator>BrianWestfall</dc:creator>
    <dc:date>2011-12-02T20:36:25Z</dc:date>
    <item>
      <title>Get layer of selected object</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298308#M7729</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need to get the layer of a single selcted object.&amp;nbsp; Using the selection tool, if a user selects a polygon, I want to determine programatically (vb.net) what layer that object is on.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 02:25:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298308#M7729</guid>
      <dc:creator>BrianWestfall</dc:creator>
      <dc:date>2011-12-02T02:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer of selected object</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298309#M7730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can get the feature from the map's feature selection.&amp;nbsp; The feature has a Class property that will tell you the feature class it comes from.&amp;nbsp; You can then loop through all of the layers in the map until you find one that uses that feature class as a datasource.&amp;nbsp; This is not foolproof as there can be any number of layers in the map that use the same feature class as a datasource.&amp;nbsp; If this is the case then you will not be able to tell which layer the feature comes from.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 12:21:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298309#M7730</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2011-12-02T12:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer of selected object</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298310#M7731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You can also loop through all the layers in the map.&amp;nbsp; You can cast the each layer to IFeatureSelection if the layer implements that interface.&amp;nbsp; You can then check each layer's selectionset for selected features.&amp;nbsp; To my knowledge this is the only way to make sure you have the right layer since, as Neil mentioned, the same featureclass can be the source for more than one layer in the map and the map's featureselection doesn't link back to the layers, only the featureclasses.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 12:47:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298310#M7731</guid>
      <dc:creator>AlexanderGray</dc:creator>
      <dc:date>2011-12-02T12:47:20Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer of selected object</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298311#M7732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alexander and Neil,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks you both for the suggestions.&amp;nbsp; The following code list the layers in a list box of any selected features.&amp;nbsp; It seems to work but do you see any problems with this approach.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brian&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; Public Sub GetLayer()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMxDoc As IMxDocument&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pMxDoc = CType(My.ArcMap.Application.Document, IMxDocument)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pMap As IMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pMap = pMxDoc.FocusMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pEnumLayer As IEnumLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pEnumLayer = pMap.Layers&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pEnumLayer.Reset()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pLayer As ILayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pLayer = pEnumLayer.Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim pFLayer As IFeatureLayer = Nothing&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Do While Not pLayer Is Nothing&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If TypeOf pLayer Is IFeatureLayer Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pFLayer = TryCast(pLayer, IFeatureLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim sel As IFeatureSelection&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sel = TryCast(pFLayer, IFeatureSelection)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If sel.SelectionSet.Count &amp;gt; 0 Then&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ListBox1.Items.Add(pLayer.Name) ' this adds the layer name to a list box&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pLayer = pEnumLayer.Next&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Loop&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; End Sub&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:00:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298311#M7732</guid>
      <dc:creator>BrianWestfall</dc:creator>
      <dc:date>2011-12-02T16:00:05Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer of selected object</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298312#M7733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The code lists any layers that have a feature selection.&amp;nbsp; It doesn't do anything to try and determine if the feature comes from one or more of them.&amp;nbsp; You could narrow down the list by checking the feature class of each layer to see if it is the same feature class the selected feature comes from.&amp;nbsp; You could narrow it down even further by checking the selection set of each layer you have left to see if it contains a feature with the same ObjectId as the selected feature.&amp;nbsp; If you find two or more layers with the same ObjectId in their selection set then I don't think you can do anything else to determine which one that feature actually belongs to (well, short of unselecting that feature and looking to see which selection set changed).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 16:52:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298312#M7733</guid>
      <dc:creator>NeilClemmons</dc:creator>
      <dc:date>2011-12-02T16:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Get layer of selected object</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298313#M7734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Good point.&amp;nbsp; Something else to figure out how to do.&amp;nbsp; I appreciate your suggestions.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Brian&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Dec 2011 20:36:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/get-layer-of-selected-object/m-p/298313#M7734</guid>
      <dc:creator>BrianWestfall</dc:creator>
      <dc:date>2011-12-02T20:36:25Z</dc:date>
    </item>
  </channel>
</rss>

