Hallo,
thanks for replying to my thread. The code I' ve written since now is below. trig_srtm30 is a point shapefile and poly_C1toend is a polygon shapefile. I want to select each point, get the coordinates of each point and then pove the whole polygon shapefile according to the coordinates I get. Thank you very much.
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.Carto
Public Class Tool1
Inherits ESRI.ArcGIS.Desktop.AddIns.Tool
#Region "Select Map Features by Attribute Query"
'''<summary>Select features in the IActiveView by an attribute query using a SQL syntax in a where clause.</summary>
'''
'''<param name="activeView">An IActiveView interface</param>
'''<param name="featureLayer">An IFeatureLayer interface to select upon</param>
'''<param name="whereClause">A System.String that is the SQL where clause syntax to select features. Example: "CityName = 'Redlands'"</param>
'''
'''<remarks>Providing and empty string "" will return all records.</remarks>
Public Sub SelectMapFeaturesByAttributeQuery(ByVal activeView As IActiveView, ByVal featureLayer As IFeatureLayer, ByVal whereClause As System.String)
If activeView Is Nothing OrElse featureLayer Is Nothing OrElse whereClause Is Nothing Then
Return
End If
Dim featureSelection As IFeatureSelection = TryCast(featureLayer, IFeatureSelection) ' Dynamic Cast
' Set up the query
Dim queryFilter As IQueryFilter = New QueryFilterClass
queryFilter.WhereClause = whereClause
' Invalidate only the selection cache. Flag the original selection
activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
' Perform the selection
featureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, False)
' Flag the new selection
activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
End Sub
#End Region
' select coords and assign to variables by select Map Features by Atribute Query
Dim row As Double
Dim pX As Double
Dim pY As Double
SelectMapFeaturesByAttributeQuery(activeView, trig_srtm30, "FID=row")
pX=trig_srtm30.X(Value)
pY=trig_srtm30.Y(Value)
#Region "Clear Selected Map Features"
'''<summary>Clear the selected features in the IActiveView for a specified IFeatureLayer.</summary>
'''
'''<param name="activeView">An IActiveView interface</param>
'''<param name="featureLayer">An IFeatureLayer</param>
'''
'''<remarks></remarks>
Public Sub ClearSelectedMapFeatures(ByVal activeView As IActiveView, ByVal featureLayer As IFeatureLayer)
If activeView Is Nothing OrElse featureLayer Is Nothing Then
Return
End If
Dim featureSelection As IFeatureSelection = TryCast(featureLayer, IFeatureSelection) ' Dynamic Cast
' Invalidate only the selection cache. Flag the original selection
activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
' Clear the selection
featureSelection.Clear()
' Flag the new selection
activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)
End Sub
#End Region
' Clear selection
ClearSelectedMapFeatures(activeView, trig_srtm30)
' select polygon shapefile which will be moved by select Map Features by Atribute Query
SelectMapFeaturesByAttributeQuery(activeView, poly_C1toend, "")
' move shapefile according to new coords
Public Sub New()
End Sub
Protected Overrides Sub OnUpdate()
Enabled = My.ArcMap.Application IsNot Nothing
End Sub
End Class