Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
Shopmotion


Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search
Affiliates
free forum
 
April 2018
MonTueWedThuFriSatSun
      1
2345678
9101112131415
16171819202122
23242526272829
30      

Calendar Calendar


Empty Geometry error related to Geometric Network

Go down

Empty Geometry error related to Geometric Network

Post  alisa ga on Sun Mar 16, 2008 9:17 am

Hi -
I have a script that combines coordinates from two different fields, does a bit of math on them and then plops that number into a new field. it works great until i try to run it with a Geometric Network built. It will place the new point and populate the fields but then i get a run-time error: operation was attempted on an empty geometry.

Any ideas? the code is listed below: thanks!





' ---- Define the field names to hold the coords ----

Const XFIELD = "xCoord"

Const YFIELD = "yCoord"

Const LOC_NUM = "LOC_NUM"

' ---------------------------------------------------

Private WithEvents m_pEditEvents As Editor



Public Sub AllowCoordFieldsToBeUpdated()

' Start listening for Edit Events

Dim pEditor As IEditor

Dim pID As New UID



pID = "esriEditor.Editor"

Set m_pEditEvents = Application.FindExtensionByCLSID(pID)



End Sub



Public Sub StopCoordFieldsBeingUpdated()

' Stop listening for edit events



Set m_pEditEvents = Nothing



End Sub



Private Sub m_pEditEvents_OnCreateFeature(ByVal obj As esriGeoDatabase.IObject)

' This sub is fired whenever a feature is created.

' If the feature is a point and has the correct fieldnames then they are updated

' with the point's coordinates.

Dim bUpdatingCoordFields As Boolean

Dim pFtr As IFeature

Dim lXFldIdx As Long

Dim lYFldIdx As Long

Dim lLOC_NUMIdx As Long



If bUpdatingCoordFields Then

bUpdatingCoordFields = False

Exit Sub

End If



If Not (TypeOf obj Is IFeature) Then Exit Sub



Set pFtr = obj

If Not (TypeOf pFtr.Shape Is IPoint) Then Exit Sub



lXFldIdx = pFtr.Fields.FindField(XFIELD)

lYFldIdx = pFtr.Fields.FindField(YFIELD)

lLOC_NUMIdx = pFtr.Fields.FindField(LOC_NUM)

If lXFldIdx = -1 Or lYFldIdx = -1 Then Exit Sub



bUpdatingCoordFields = True

UpdatePointFeatureWithCoords pFtr, lXFldIdx, lYFldIdx, lLOC_NUMIdx





End Sub





Private Sub m_pEditEvents_OnChangeFeature(ByVal obj As esriGeoDatabase.IObject)

' This sub is fired whenever an existing feature is edited.

' If the feature is a point and has the correct fieldnames then they are updated

' with the point's coordinates. As this is an edit, it will also fire this sub,

' so we use a static variable to inform the sub that we're updating the coord fields

' and just to exit the sub

Dim bUpdatingCoordFields As Boolean

Dim pFtr As IFeature

Dim lXFldIdx As Long

Dim lYFldIdx As Long

Dim lLOC_NUMIdx As Long





If bUpdatingCoordFields Then

bUpdatingCoordFields = False

Exit Sub

End If



If Not (TypeOf obj Is IFeature) Then Exit Sub



Set pFtr = obj

If Not (TypeOf pFtr.Shape Is IPoint) Then Exit Sub



lXFldIdx = pFtr.Fields.FindField(XFIELD)

lYFldIdx = pFtr.Fields.FindField(YFIELD)

lLOC_NUMIdx = pFtr.Fields.FindField(LOC_NUM)

If lXFldIdx = -1 Or lYFldIdx = -1 Then Exit Sub



bUpdatingCoordFields = True

UpdatePointFeatureWithCoords pFtr, lXFldIdx, lYFldIdx, lLOC_NUMIdx



End Sub



Private Sub UpdatePointFeatureWithCoords(pFtr As IFeature, lXFldIdx As Long, lYFldIdx As Long, lLOC_NUMIdx As Long)

' Updates the point feature attributes with the coords of the point



Dim pPt As IPoint

Dim sxpoint

Dim sypoint

Dim scnumtemp



Set pPt = pFtr.Shape

pFtr.Value(lXFldIdx) = pPt.X

pFtr.Value(lYFldIdx) = pPt.Y

sxpoint = Int(pPt.X - 1000000)

sypoint = Int(pPt.Y - 1000000)

scnumtemp = sxpoint & sypoint



If (Len(scnumtemp) < 13) Then

scnumtemp = 0 & scnumtemp

End If



pFtr.Value(lLOC_NUMIdx) = scnumtemp

pFtr.Store

End Sub

'Private Function MxDocument_OpenDocument() As Boolean

'Call AllowCoordFieldsToBeUpdated

'End Function

Private Function MxDocument_ActiveViewChanged() As Boolean

End Function

'Private Function MxDocument_OpenDocument() As Boolean

'End Function

alisa ga
Guest


Back to top Go down

Re: Empty Geometry error related to Geometric Network

Post  manoj ga on Sun Mar 16, 2008 9:18 am

am not a developer but I can tell that when you place a point by using some program, you need to create an envelop and rebuilt/repair connectivityor rebuilt connectivity after creating all point but before editing.

Thanks
Manoj Garg

manoj ga
Guest


Back to top Go down

Craig Gillgrass

Post  Re: Empt on Sun Mar 16, 2008 9:19 am

You should never have to Rebuild\Repair Connectivity after adding a new feature. The Geometric Network will update and determine all connectivity that is needed.

If you are using Rebuild\Repair Connectivity in a standard workflow, can you provide me with more information?

thanks,
Craig Gillgrass

Re: Empt
Guest


Back to top Go down

alisa gardiner

Post  reply on Sun Mar 16, 2008 9:20 am

I didn't THINK you'd have to manually rebuild/repair something - this is not part of our flow - I rely on the GN to do all of that for me. For what it's worth I have run all of the error-seeking tools on the GDB and the data would appear to be as clean as it can be, no errors reported.

reply
Guest


Back to top Go down

Re: Empty Geometry error related to Geometric Network

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum