Select to view content in your preferred language

Coordinates or measures are out of bounds

3326
1
09-17-2010 04:27 AM
SteffenKeller
Emerging Contributor
Hello all,

I use VBA in ArcMap 9.3.1:
- I have a polygon-layer (in SDE-GeoDatabase) loaded
- the editor is started and the target is the polygon-layer

I run the code below (Map.ClearSelection and then a Attribute-Selection). One polygon is now selected.
Then I use the "Edit Tool" from the Editor-Toolbar and I try to move the polygon. The polygon keeps on his place and I get a message "The feature(s) could not be moved. The coordinates or measures are out of bounds."

When I close this message-box and I try to move the feature again, it moves correctly.
When I comment out the line "pMap.ClearSelection" and run the code, the polygon moves at first attempt without any error-message.

What's wrong ?

harpo


Code:

Public Sub SelFeatures()

  Dim pMxDoc As IMxDocument
  Dim pMap As IMap
  Dim pFeatSel As IFeatureSelection
  Dim pQF As IQueryFilter
  Dim pSelSet As ISelectionSet
 
  Set pMxDoc = Application.Document
  Set pMap = pMxDoc.FocusMap

  pMap.ClearSelection

  Set pFeatSel = pMap.Layer(0)

  Set pQF = New QueryFilter
  pQF.WhereClause = "OBJECTID = 1"
 
  pFeatSel.SelectFeatures pQF, esriSelectionResultNew, False
  pFeatSel.SelectionChanged
  pMxDoc.ActiveView.Refresh
 
  Set pSelSet = pFeatSel.SelectionSet
  Debug.Print pSelSet.Count
 
End Sub
0 Kudos
1 Reply
SteffenKeller
Emerging Contributor
🙂 I solved the problem by myself:

The reason is, that the SelectionAnchor-Point is not automatically displayed or updated.
I added the following (bold) lines, so the code is now:

Public Sub SelFeatures()

Dim pMxDoc As IMxDocument
Dim pMap As IMap
Dim pFeatSel As IFeatureSelection
Dim pQF As IQueryFilter
Dim pSelSet As ISelectionSet

Set pMxDoc = Application.Document
Set pMap = pMxDoc.FocusMap

Dim pEditor As IEditor
Dim pID As New UID
pID = "esriEditor.Editor"
Set pEditor = Application.FindExtensionByCLSID(pID)


pMap.ClearSelection

Set pFeatSel = pMap.Layer(0)

Set pQF = New QueryFilter
pQF.WhereClause = "OBJECTID = 1"

pFeatSel.SelectFeatures pQF, esriSelectionResultNew, False
pFeatSel.SelectionChanged

If TypeOf pEditor.EditSelection.Next.Shape Is Polygon Then
  Set pPolygon = pEditor.EditSelection.Next.Shape
  Set pArea = pPolygon
  pEditor.SelectionAnchor.MoveTo pArea.LabelPoint, pEditor.Display
End If


pMxDoc.ActiveView.Refresh

Set pSelSet = pFeatSel.SelectionSet
Debug.Print pSelSet.Count

End Sub
0 Kudos