FeatureDataConverter の使用方法

 2016/9/1 (木)    

Private Sub ConvertFeatureClassOperation()
    'レイヤからフィーチャクラスを取得
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
     
    Dim pFeatureLayer As IFeatureLayer
    Set pFeatureLayer = pMxDocument.FocusMap.Layer(0)
     
    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeatureLayer.FeatureClass
     
    Dim pInDataset As IDataset
    Set pInDataset = pFeatureClass
     
    Dim pInWorkspace As IWorkspace
    Set pInWorkspace = pInDataset.Workspace
     
    Dim pWorkspaceEdit As IWorkspaceEdit
    Set pWorkspaceEdit = pInWorkspace
     
     
    '入力FeatureClassName(WorkspaceNameも保持)
    Dim pInDatasetName As IDatasetName
    Set pInDatasetName = pInDataset.FullName
     
    '出力FeatureWorkspaceName設定
    Dim pOutWorkspaceName As IWorkspaceName
    Set pOutWorkspaceName = New WorkspaceName
    pOutWorkspaceName.WorkspaceFactoryProgID = "esriDataSourceFile.ShapefileWorkspaceFactory"
    pOutWorkspaceName.PathName = "D:\Workspace"
     
    '出力FeatureClassName
    Dim pOutFeatureClassName As IFeatureClassName
    Dim pOutFeatureClassDatasetName As IDatasetName
     
    Set pOutFeatureClassName = New FeatureClassName
    Set pOutFeatureClassDatasetName = pOutFeatureClassName
     
    pOutFeatureClassName.FeatureType = esriFTSimple
    pOutFeatureClassName.ShapeFieldName = pFeatureClass.ShapeFieldName
    pOutFeatureClassName.ShapeType = esriGeometryAny
     
    pOutFeatureClassDatasetName.Name = pFeatureClass.AliasName          '出力フィーチャクラス名
    Set pOutFeatureClassDatasetName.WorkspaceName = pOutWorkspaceName   'Workspaceの指定
     
    pWorkspaceEdit.StartEditOperation
    pWorkspaceEdit.StartEditing True
     
    Dim pFeatureDataConverter  As IFeatureDataConverter2
    Set pFeatureDataConverter = New FeatureDataConverter
    pFeatureDataConverter.ConvertFeatureClass pInDatasetName, Nothing, Nothing, Nothing, pOutFeatureClassName, Nothing, Nothing, "", 100, Application.hWnd
     
    pWorkspaceEdit.StopEditing True
    pWorkspaceEdit.StopEditOperation
     
    MsgBox "[" & pOutWorkspaceName.PathName & "]に[" & pOutFeatureClassDatasetName.Name & "]を作成しました。"
     
End Sub

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.