zoukankan      html  css  js  c++  java
  • 生成N个点的工具,和生成N个多边形的工具

    //后来发现插入feature,可以不用
        pWorkSpaceEdit.StartEditing True
        pWorkSpaceEdit.StartEditOperation

    *********************************
        pWorkSpaceEdit.StopEditing True
        pWorkSpaceEdit.StopEditOperation

    //编辑的时候才需要
    Private Sub CommandButton1_Click()

    Dim PolyCount As Integer
    PolyCount = Val(TextBox1.Text)
    Dim i As Integer

    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 pFeaturelayer As IFeatureLayer
    Set pFeaturelayer = pMap.Layer(0)

    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeaturelayer.FeatureClass


    Dim pDataSet As IDataset
    Set pDataSet = pFeatureClass

    Dim pWorkSpace As IWorkspace
    Set pWorkSpace = pDataSet.Workspace

    Dim pWorkSpaceEdit As IWorkspaceEdit
    Set pWorkSpaceEdit = pWorkSpace


        pWorkSpaceEdit.StartEditing True
        pWorkSpaceEdit.StartEditOperation

        
        For i = 0 To PolyCount - 1
        
        Dim pFeature As IFeature
        Set pFeature = pFeatureClass.CreateFeature
        Dim pPoint As IPoint
        Set pPoint = New Point
        pPoint.PutCoords 10000000000000# * Rnd, 10000000000000# * Rnd
        Set pFeature.Shape = pPoint
        Dim pFields As IFields
        Set pFields = pFeatureClass.Fields
        Dim idx As Integer
        idx = pFields.FindField("Name")
        pFeature.Value(idx) = "武汉" & i
        pFeature.Store
        
        Next i
        
        pActiveView.Refresh
     
     
    pWorkSpaceEdit.StopEditing True

    End Sub

    ‘=======================================

    Private Sub CommandButton1_Click()

    Dim PolyCount As Integer
    PolyCount = Val(TextBox1.Text)
    Dim i As Integer

    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 pFeaturelayer As IFeatureLayer
    Set pFeaturelayer = pMap.Layer(0)

    Dim pFeatureClass As IFeatureClass
    Set pFeatureClass = pFeaturelayer.FeatureClass


    Dim pDataSet As IDataset
    Set pDataSet = pFeatureClass

    Dim pWorkSpace As IWorkspace
    Set pWorkSpace = pDataSet.Workspace

    Dim pWorkSpaceEdit As IWorkspaceEdit
    Set pWorkSpaceEdit = pWorkSpace

        pWorkSpaceEdit.StartEditing True
        pWorkSpaceEdit.StartEditOperation

        
        For i = 0 To PolyCount - 1
        
        Dim pFeature As IFeature
        Set pFeature = pFeatureClass.CreateFeature
        Dim pPointCollection4 As IPointCollection4
        Set pPointCollection4 = New Polygon
        Dim pPolygon As IPolygon
        Set pPolygon = pPointCollection4
        
        Dim pPoint As IPoint
        Set pPoint = New Point
        pPoint.PutCoords 571 * Rnd - 450, 351 * Rnd - 90
        pPointCollection4.AddPoint pPoint
        
     
        Set pPoint = New Point
        pPoint.PutCoords 571 * Rnd - 450, 351 * Rnd - 90
         pPointCollection4.AddPoint pPoint
     
        Set pPoint = New Point
        pPoint.PutCoords 571 * Rnd - 450, 351 * Rnd - 90
        pPointCollection4.AddPoint pPoint
         
         
        Set pFeature.Shape = pPolygon
        Dim pFields As IFields
        Set pFields = pFeatureClass.Fields
        Dim idx As Integer
        idx = pFields.FindField("Name")
        pFeature.Value(idx) = "武汉" & i
        pFeature.Store
        
        Next i
        
        pActiveView.Refresh
     
     
    pWorkSpaceEdit.StopEditing True
    End Sub

     

  • 相关阅读:
    浙江省CIO协会钱塘江论坛近日在网易云创沙龙宣布成立
    用Python解析XMind
    Flask写web时cookie的处理
    一篇文章看懂Facebook和新浪微博的智能FEED
    改进网易云音乐的“音乐社交”构想
    移动端爬虫工具与方法介绍
    用供应链管理思路降低教培产品成本
    【网易严选】iOS持续集成打包(Jenkins+fastlane+nginx)
    网易严选的wkwebview测试之路
    linux多进程之间的文件锁
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1395420.html
Copyright © 2011-2022 走看看