简单VBA添加线要素

来源:互联网 发布:怎么目测身高知乎 编辑:程序博客网 时间:2024/05/16 17:11
Dim pMxd As IMxDocument
Set pMxd = Application.Document
Dim pFeaturelayer As IFeatureLayer
Dim pFeatureClass As IFeatureClass
   Set pFeaturelayer = pMxd.SelectedLayer
    Set pFeatureClass = pFeaturelayer.FeatureClass
Dim pLine As IPointCollection
Set pLine = New Polyline
Dim pPoint1 As IPoint
Set pPoint1 = New Point
    pPoint1.X = 114.529
    pPoint1.Y = 37.948
Dim pPoint2 As IPoint
Set pPoint2 = New Point
    pPoint2.X = 114.469
    pPoint2.Y = 37.981
 pLine.AddPoint pPoint1
 Dim pFeature As IFeature
    Set pFeature = pFeatureClass.CreateFeature
    MsgBox pFeature.FeatureType
    Set pFeature.Shape = pLine
    pFeature.Store
    MsgBox pFeature.OID