You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects Visual Basic for Application (VBA) forum

IWorkspaceEdit and mousedown   Tony Almeida Mar 15, 2010
Re: IWorkspaceEdit and mousedown   Tony Almeida Mar 17, 2010
Re: IWorkspaceEdit and mousedown   Tony Almeida Apr 02, 2010
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject IWorkspaceEdit and mousedown 
Author Tony Almeida 
Date Mar 15, 2010 
Message I have tool that creates points based on clicks. Tool works great as a shapefile, but i can't seem to get to work on an SDE feature class.

I get the following error:
One or more layers failed to draw:

FDO error: 0
The requested operation is invalid on a closed state[dsd."CC\*****".CC_Address_Points]

from what i have read i need to implement the StartEditing but i don't know how

Thanks.
 
 
Dim pFeature1 As IFeature
Dim tmpPoint1 As IPoint


Private Sub UIToolControl2_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)


        'Adds a point to a shapefile
    Dim pMap As IMap
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
    Set pMap = pMxDoc.FocusMap

    'Get the first layer in the map
    Dim pFeatLyr As IGeoFeatureLayer
    Set pFeatLyr = pMap.Layer(0)

     'Create a point from the mouse down click
    Dim tmpPoint As IPoint
    Set tmpPoint = New Point
    Set tmpPoint = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)

    'Get the feature class
    Dim pFClass As IFeatureClass
    Set pFClass = pFeatLyr.FeatureClass

    'Create the new point feature
    Dim pfeature As IFeature
    Dim dblDist As Double
    If button = 2 Then
        Set pFeature1 = Nothing
        Set tmpPoint1 = Nothing
        Exit Sub
    End If
    If pFeature1 Is Nothing Then
        If tmpPoint1 Is Nothing Then
            Set tmpPoint1 = tmpPoint
        Else
            Set pfeature = pFClass.CreateFeature
            Set pfeature.Shape = tmpPoint
            If Not tmpPoint1 Is Nothing Then
                dblDist = 0
                dblDist = GetDistance1(pfeature)
                pfeature.Value(pfeature.Class.Fields.FindField("Distance")) = dblDist
                pfeature.Value(pfeature.Class.Fields.FindField("SiteNum")) = (dblDist / 5.28) + InputBox("Enter Address Range") & ""
                pfeature.Store
            End If
            Set pFeature1 = pfeature
        End If
    Else
        Set pfeature = pFClass.CreateFeature
        Set pfeature.Shape = tmpPoint
        If Not pFeature1 Is Nothing Then
            dblDist = 0
            dblDist = GetDistance(pFeature1, pfeature)
            pfeature.Value(pfeature.Class.Fields.FindField("Distance")) = dblDist
            pfeature.Value(pfeature.Class.Fields.FindField("SiteNum")) = (dblDist / 5.28) + InputBox("Enter Address Range") & ""

            pfeature.Store
        End If
        Set pFeature1 = pfeature
    End If
    pMxDoc.ActiveView.Refresh
    pMxDoc.UpdateContents
End Sub
Function GetDistance1(pFeature1 As IFeature) As Double
    Dim pGeom1 As IGeometry
    Dim pGeom2 As IGeometry
    Dim pProx As IProximityOperator
    Dim dblDist As Double
    Set pGeom1 = tmpPoint1
    Set pGeom2 = pFeature1.Shape
    Set pProx = pGeom2
    dblDist = pProx.ReturnDistance(pGeom1)
    'MsgBox dblDist
    GetDistance1 = dblDist
End Function
Function GetDistance(pFeature1 As IFeature, pFeature2 As IFeature) As Double
    Dim pGeom1 As IGeometry
    Dim pGeom2 As IGeometry
    Dim pProx As IProximityOperator
    Dim dblDist As Double
    Set pGeom1 = pFeature1.Shape
    Set pGeom2 = pFeature2.Shape
    Set pProx = pGeom2
    dblDist = pProx.ReturnDistance(pGeom1)
    'MsgBox dblDist
    GetDistance = dblDist
End Function
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: IWorkspaceEdit and mousedown 
Author Tony Almeida 
Date Mar 17, 2010 
Message Correction i get a Run-time error when i don't start an edit session.

"Objects in this class connot be updated outside an edit session."

When i start an edit session under editor, start editing. I get the following error..

FDO error: 0
The requested operation is invalid on a closed state[dsd..CC_Address_Points]

Anyone have any ideas?

Thanks. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: IWorkspaceEdit and mousedown 
Author Tony Almeida 
Date Apr 02, 2010 
Message Any one have any suggestions?