選択されているレイヤのワークスペースを対象に編集を開始する方法

 2016/9/1 (木)    

'選択レイヤのワークスペースで編集開始
Private WithEvents EditEvents As Editor
Private m_pEditor As IEditor
 
Private Sub StartEditing()
    '------------- 選択レイヤのチェック ----------------------------------
    Dim pMxDoc As IMxDocument
    Set pMxDoc = ThisDocument
     
    If pMxDoc.SelectedLayer Is Nothing Then
        MsgBox "編集するレイヤをTOCで最初に選択してください", vbExclamation
         
        Set pMxDoc = Nothing
        Exit Sub
     
    End If
     
    '---------- 編集セッションを開始してEditEventsをIEditorをQI -----------
    Dim pApp As Application
    Set pApp = Application
     
    Dim pUID As New UID
    pUID = "esriEditor.Editor"
'    puid = "esricore.Editor"
     
    'Dim pEditor As IEditor
    Set m_pEditor = pApp.FindExtensionByCLSID(pUID)
    Set EditEvents = m_pEditor  'ここでIEditorのイベントセット
     
    Dim pFLayer As IFeatureLayer2
    Set pFLayer = pMxDoc.SelectedLayer
     
    Dim pDataset As IDataset
    Set pDataset = pFLayer.FeatureClass
     
    Dim pWorkspace As IWorkspace
    Set pWorkspace = pDataset.Workspace
     
    m_pEditor.StartEditing pWorkspace
     
    '---------- 編集ターゲットをTOCでの選択レイヤにする -------------------
     
    Dim pEditLayers As IEditLayers
    Set pEditLayers = m_pEditor
     
    pEditLayers.SetCurrentLayer pFLayer, 0
     
End Sub

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.