• arcmap vba 生成3维侧棱 以及 createfeature与createfeaturebuffer的区别


    Sub huaxian()
    Dim pMxDoc As IMxDocument
    Set pMxDoc = Application.Document

    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap

    Dim pActiveView As IActiveView
    Set pActiveView = pMxDoc.FocusMap

    Dim pFeatureClassOne As IFeatureClass
    Dim pFLayerOne As IFeatureLayer

    Dim pFeatureClassTwo As IFeatureClass
    Dim pFLayerTwo As IFeatureLayer

    Dim pFeatureClassNew As IFeatureClass
    Dim pFLayerNew As IFeatureLayer

    Set pFLayerOne = pMap.Layer(0)
    Set pFLayerTwo = pMap.Layer(1)
    Set pFLayerNew = pMap.Layer(2)

    Set pFeatureClassOne = pFLayerOne.FeatureClass
    Set pFeatureClassTwo = pFLayerTwo.FeatureClass
    Set pFeatureClassNew = pFLayerNew.FeatureClass

    Dim pFeatureCursorOne As IFeatureCursor
    Dim pFeatureCursorTwo As IFeatureCursor

    Set pFeatureCursorOne = pFeatureClassOne.Search(Nothing, True)
    Set pFeatureCursorTwo = pFeatureClassTwo.Search(Nothing, True)

    Dim pFeatureOne As IFeature
    Dim pFeatureTwo As IFeature

    Set pFeatureOne = pFeatureCursorOne.NextFeature
    Set pFeatureTwo = pFeatureCursorTwo.NextFeature


    Dim pPolygonOne As IPolygon
    Dim pPolygonTwo As IPolygon
    Dim pOnePoints As IPointCollection
    Dim pTwoPoints As IPointCollection
    Dim i As Integer

    Dim pFromPoint As IPoint
    Dim pToPoint As IPoint
    Dim pPolyline As IPolyline
    Dim polylinePoints As IPointCollection
    Dim pFeatureNew As IFeature

     'create a feature cursor and feature buffer interface
     Dim pFeatCur As IFeatureCursor
     Dim pFeatBuf As IFeatureBuffer
     
     'open the feature cursor and feature buffer
     Set pFeatCur = pFeatureClassNew.Insert(True)
     Set pFeatBuf = pFeatureClassNew.CreateFeatureBuffer

     Dim q As Long

     
    While Not pFeatureOne Is Nothing And Not pFeatureTwo Is Nothing
       Set pPolygonOne = pFeatureOne.Shape
       Set pPolygonTwo = pFeatureTwo.Shape
       Set pOnePoints = pPolygonOne
       Set pTwoPoints = pPolygonTwo
     
     For i = 0 To pOnePoints.PointCount - 1
      
       Set pFromPoint = pOnePoints.Point(i)
       Set pToPoint = pTwoPoints.Point(i)
       Set pPolyline = New Polyline
       Set polylinePoints = pPolyline
      
       polylinePoints.AddPoint pFromPoint
       polylinePoints.AddPoint pToPoint
      
       Set pFeatureNew = pFeatBuf
       Set pFeatureNew.Shape = pPolyline
     


       q = pFeatCur.InsertFeature(pFeatBuf)
      
       Next i
      
       Set pFeatureOne = pFeatureCursorOne.NextFeature
       Set pFeatureTwo = pFeatureCursorTwo.NextFeature
    Wend

    MsgBox "done!"
    End Sub

    ——————————————————————————————————————————————————————————————————————

    Sub huaxian()

    Dim pMxDoc As IMxDocument
    Set pMxDoc = Application.Document

    Dim pMap As IMap
    Set pMap = pMxDoc.FocusMap

    Dim pActiveView As IActiveView
    Set pActiveView = pMxDoc.FocusMap

    Dim pFeatureClassOne As IFeatureClass
    Dim pFLayerOne As IFeatureLayer

    Dim pFeatureClassTwo As IFeatureClass
    Dim pFLayerTwo As IFeatureLayer

    Dim pFeatureClassNew As IFeatureClass
    Dim pFLayerNew As IFeatureLayer

    Set pFLayerOne = pMap.Layer(0)
    Set pFLayerTwo = pMap.Layer(1)
    Set pFLayerNew = pMap.Layer(2)

    Set pFeatureClassOne = pFLayerOne.FeatureClass
    Set pFeatureClassTwo = pFLayerTwo.FeatureClass
    Set pFeatureClassNew = pFLayerNew.FeatureClass

    Dim pFeatureCursorOne As IFeatureCursor
    Dim pFeatureCursorTwo As IFeatureCursor

    Set pFeatureCursorOne = pFeatureClassOne.Search(Nothing, True)
    Set pFeatureCursorTwo = pFeatureClassTwo.Search(Nothing, True)

    Dim pFeatureOne As IFeature
    Dim pFeatureTwo As IFeature

    Set pFeatureOne = pFeatureCursorOne.NextFeature
    Set pFeatureTwo = pFeatureCursorTwo.NextFeature


    Dim pPolygonOne As IPolygon
    Dim pPolygonTwo As IPolygon
    Dim pOnePoints As IPointCollection
    Dim pTwoPoints As IPointCollection
    Dim i As Integer

    Dim pFromPoint As IPoint
    Dim pToPoint As IPoint
    Dim pPolyline As IPolyline
    Dim polylinePoints As IPointCollection
    Dim pFeatureNew As IFeature


     
    While Not pFeatureOne Is Nothing and Not pFeatureTwo Is Nothing
       Set pPolygonOne = pFeatureOne.Shape
       Set pPolygonTwo = pFeatureTwo.Shape
       Set pOnePoints = pPolygonOne
       Set pTwoPoints = pPolygonTwo
     
     For i = 0 To pOnePoints.PointCount - 1
      
       Set pFromPoint = pOnePoints.Point(i)
       Set pToPoint = pTwoPoints.Point(i)
       Set pPolyline = New Polyline
       Set polylinePoints = pPolyline
      
       polylinePoints.AddPoint pFromPoint
       polylinePoints.AddPoint pToPoint
      
       Set pFeatureNew = pFeatureClassNew.CreateFeature
       Set pFeatureNew.Shape = pPolyline
       pFeatureNew.Store
      
      
      
      
       Next i
      
       Set pFeatureOne = pFeatureCursorOne.NextFeature
       Set pFeatureTwo = pFeatureCursorTwo.NextFeature
    Wend

    MsgBox "done!"


    End Sub


     

  • 相关阅读:
    如何使页面中的INPUT按指定的顺序移动焦点{转}
    Eclipse把包引入到项目中的方法
    mssqlserver和sqlexpress的区别{转}
    WPF中动态加载XAML中的控件
    修改Eclipse的智能感知设置
    格式化包括字符串, 数字, 日期, 枚举等类型数据的格式化
    ASP.NET身份验证机制membership入门——配置篇(1){转}
    JAVA基础总结{转}
    asp.net mvc的生命周期{转}
    使用开源免费类库在.net中操作Excel{转}
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1771510.html
Copyright © 2020-2023  润新知