Wednesday, December 13, 2006

point decimal.. code

In ArcGIS 9.1 ... its kinda hard to select a point and display the coordinates in complete decimals... cause it gets truncated. You can try to use edit sketch to see the points... but the decimal placings is not complete.

Here is an ArcObject code that can do both:

Private Sub MovePointTo()
Dim pInput As String
Dim pOrigPoint As IPoint
Dim pFeat As IFeature
Dim pEnum As IEnumFeature
Dim pX As Double
Dim pArea As IArea
Dim pEnv As IEnvelope
Dim pY As Double
Dim pDestPoint As IPoint
Dim pMx As IMxDocument
Set pMx = ThisDocument
If pMx.FocusMap.SelectionCount = 0 Or pMx.FocusMap.SelectionCount > 1 Then
MsgBox "select only one point feature"
Exit Sub
End If
Set pEnum = pMx.FocusMap.FeatureSelection
Set pFeat = pEnum.Next
Set pOrigPoint = pFeat.Shape
pInput = InputBox("Enter XY coordinates separated by space: Ex 100 -100")
pVal = Split(pInput, " ", -1, vbTextCompare)
If UBound(pVal) > 1 Then
MsgBox "Enter only XY: Example 212.55 522.11"
Exit Sub
Else
pX = pVal(0)
pY = pVal(1)
Set pDestPoint = New point
pDestPoint.PutCoords pX, pY
Set pFeat.Shape = pDestPoint
pFeat.Store
Set pArea = pFeat.Shape.Envelope
Set pEnv = pMx.ActiveView.Extent
pEnv.CenterAt pArea.Centroid
pMx.ActiveView.Extent = pEnv
pMx.ActiveView.Refresh
End If
End Sub

Private Sub UIButtonControl1_Click()
MovePointTo
End Sub

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home