I can successfully get all layers in the TOC into a combo box, but I only want to get layers that are of a polyline geometry in the TOC. My apologies, I do not know the proper method for inserting code here.
Solved! Go to Solution.
Thank you Mody - this got me going in the right direction. Instead of using ILayer, I used IFeatureLayer. I was then able to check each layer to identify IFeatureClass(es), which allowed me to access the geometry and return only polyline types. This class is designed to iterate through the current mxd layers, and populate a combobox with polyline layers only, via an add-in button.
Try if ( fLayers.FeatureClass.ShapeType = esriGeometryType.esriGeometryPolyline)
I am not sure about VB syntex but this is the way.
You can also give parameter to the My.ArcMap.Document.FocusMap.Layers to get only featurelayers.
Have fun
Mody
Thank you Mody - this got me going in the right direction. Instead of using ILayer, I used IFeatureLayer. I was then able to check each layer to identify IFeatureClass(es), which allowed me to access the geometry and return only polyline types. This class is designed to iterate through the current mxd layers, and populate a combobox with polyline layers only, via an add-in button.
One thing to be aware of. When you're cycling through the layers of your map, you may have other layers in there that are not feature layers. That would crash your code. You should use this code to make sure it is.
Dim pLayer As ESRI.ArcGIS.Carto.ILayer2
myEnumLayers = My.ArcMap.Document.FocusMap.Layers
pLayer = pEnumLayers.Next
Do Until pLayer Is Nothing
If TypeOf pLayer Is ESRI.ArcGIS.Carto.IFeatureLayer Then
pFLayer = New ESRI.ArcGIS.Carto.FeatureLayer
pFLayer = pLayer
' your additional code
End If
pLayer = pEnumLayers.Next
Loop