UIToolControl による簡易編集ツール

 2016/9/1 (木)    

Private Const IDX As Integer = 0
 
Private Sub UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, ByVal x As Long, ByVal y As Long)
 
    Dim pEditor As IEditor
    Set pEditor = Application.FindExtensionByName("esriEditor.Editor")
     
    If pEditor.EditState = esriStateNotEditing Then
        MsgBox "編集セッションを開始してください。"
        Exit Sub
     
    End If
     
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
     
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pMxDocument.FocusMap.Layer(IDX)
     
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeatureLayer.FeatureClass
     
    pEditor.StartOperation
     
    Dim pGeometry As IGeometry
    Dim pRubberBand As IRubberBand
    Set pRubberBand = New RubberPolygon 'ポリゴン
     
    Set pGeometry = pRubberBand.TrackNew(pMxDocument.ActiveView.ScreenDisplay, Nothing)
     
     
    Dim pFeature As IFeature
    Set pFeature = pFeatureClass.CreateFeature
     
    Set pFeature.Shape = pGeometry
    pFeature.Store
     
    pEditor.StopOperation ("Create")
     
    pMxDocument.ActiveView.Refresh
End Sub

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.