monalakade84

Help me for  this code

Discussion created by monalakade84 on Apr 14, 2010
Hello All

                       According to this code  I can find common end node for lines in the segment layer. but now I want common start node also. if  I change x and y position(for same code which used to find common end node) , I get common start node also but now I want to run this code for common start and end node at in one time(integration of both code). so please tel me where I should change I m sendig one attachment just check it and code is given bellow:

Sub FindCommonToNode()

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pFlayer As IFeatureLayer
Dim pFsel As IFeatureSelection
Dim pSelset As ISelectionSet
Dim pFeature As IFeature
Dim pFCur As IFeatureCursor
Dim ppolyline As IPolyline
Dim ppolyline2 As IPolyline
Dim pPoint As IPoint
Dim pPointcollection As IPointCollection
Dim p1 As IPoint
Dim p2 As IPoint
Dim pGCont As IGraphicsContainer
Dim pGrlayer As IGraphicsLayer
Dim pMelement As IMarkerElement
Dim pElement As IElement
Dim pActive As IActiveView

'Get the current map
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap

'Get the first layer in the map
Set pFlayer = pMap.Layer(0)

'Get the selected features from the layer
Set pFsel = pFlayer
Set pSelset = pFsel.SelectionSet

'Make sure that feature is selected
If pFsel.SelectionSet.Count < 1 Then
MsgBox "Please select feature"
Exit Sub
End If

pSelset.Search Nothing, False, pFCur
Set pFeature = pFCur.NextFeature

Do Until pFeature Is Nothing

Set ppolyline = pFeature.Shape
Set pFeature = pFCur.NextFeature
Set ppolyline2 = pFeature.Shape

Set p1 = ppolyline.ToPoint
Set p2 = ppolyline2.ToPoint

Set pGrlayer = pMap.BasicGraphicsLayer
Set pGCont = pGrlayer
Set pActive = pMxDoc.ActiveView
Set pPointcollection = ppolyline

'For i = 0 To pPointcollection.PointCount - 1

'Set pPoint = pPointcollection.Point(pPointcollection.PointCount - 1)
'Set pPoint = pPointcollection.Point(pPointcollection.PointCount - 1)

'To get common End point node
If (p1.X = p2.X) And (p1.Y = p2.Y) Then
Set pMelement = New MarkerElement
Set pElement = pMelement
pMelement.Symbol = New SimpleMarkerSymbol
pElement.Geometry = p1
pGCont.AddElement pElement, 0
pActive.Refresh
'do nothing
ElseIf (p1.X = p2.Y) And (p1.Y = p2.X) Then
MsgBox "No  Error"
'do nothing
End If
Set pFeature = pFCur.NextFeature
Loop
End Sub

Attachments

Outcomes