ネットワーク データセットの範囲指定ビルド

 2016/9/1 (木)    

Public Sub Build()
 
On Error GoTo Error:
 
    Dim pMxDocument As IMxDocument
    Set pMxDocument = ThisDocument
 
    Dim pMap As IMap
    Set pMap = pMxDocument.FocusMap
     
    Dim pSelection As ISelection
    Set pSelection = pMap.FeatureSelection
     
    Dim pEnumFeature As IEnumFeature
    Set pEnumFeature = pSelection
    pEnumFeature.Reset
     
    Dim pFeature As IFeature
    Set pFeature = pEnumFeature.Next
     
    Dim pGeometryBag As IGeometryBag
    Set pGeometryBag = New GeometryBag
    Dim pGeometryCollection As IGeometryCollection
    Set pGeometryCollection = pGeometryBag
     
     
    Do Until pFeature Is Nothing
     
        pGeometryCollection.AddGeometry pFeature.Shape
     
        Set pFeature = pEnumFeature.Next
    Loop
     
     
    'レイヤ
    Dim pNetworkLayer As INetworkLayer
    Set pNetworkLayer = pMxDocument.FocusMap.Layer(InputBox("ネットワーク レイヤのインデックス番号を指定してください(最上位=0)"))
     
    Dim pNetworkDataset As INetworkDataset
    Set pNetworkDataset = pNetworkLayer.NetworkDataset
     
    Dim pNetworkBuild As INetworkBuild
    Set pNetworkBuild = pNetworkDataset
     
    Dim pEnvelope As IEnvelope
    Set pEnvelope = pNetworkBuild.BuildNetwork(pGeometryBag.Envelope)
     
    MsgBox "Done"
     
    Exit Sub
     
Error:
     
    MsgBox Err.Description
    Debug.Print Err.Description
 
End Sub

Copyright© WINGFIELD since1981 , 2018 All Rights Reserved.