編集オペレーションとオペレーション スタックの連動

投稿日:2016/9/1 (木) 更新日:

Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
 
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
     
    Dim pFL As IFeatureLayer
    Set pFL = pMxDoc.FocusMap.Layer(0)
     
    Dim pFC As IFeatureClass
    Set pFC = pFL.FeatureClass
     
    Dim pFeature As IFeature
     
    Dim pUID As New UID
    pUID.Value = "esriEditor.Editor"
     
    Dim pEditor As IEditor
    Set pEditor = Application.FindExtensionByCLSID(pUID)
     
    pEditor.StartOperation
     
    Dim pPoint As IPoint
    Set pPoint = pMxDoc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)
     
    Set pFeature = pFC.CreateFeature
    Set pFeature.Shape = pPoint
     
    pFeature.Store
     
    pEditor.StopOperation "create"
     
    pMxDoc.ActiveView.Refresh
 
End Sub
 
 
Sub UndoEditOperation()
     
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
     
    Dim pOS As IOperationStack
    Set pOS = pMxDoc.OperationStack
     
    pOS.Undo
     
    pMxDoc.ActiveView.Refresh
 
End Sub

関連記事

-プログラミング, ArcGIS
-, ,

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.