新建 文本文档.txt

来自「ao的一些代码集合」· 文本 代码 · 共 21 行

TXT
21
字号
'选择要素
Sub SelectFeatures()

  Dim mxDoc As IMxDocument    '地图文档
  Dim lyr As IFeatureLayer    '要素层
  Dim sel As IFeatureSelection    '选择集
  Dim filter As IQueryFilter    '查询过滤器
  Dim selEvents As ISelectionEvents    '???

  Set mxDoc = Application.Document    '获取当前地图文档
  Set lyr = FindLayer(mxDoc.FocusMap, "BUILDING")    '调用FindLayer函数查找图层
  Set sel = lyr    '将找到的图层设为选择集
  Set filter = New QueryFilter    '创建查询过滤器
  filter.WhereClause = "BDNAME ='实验楼A'"    '设置where子句
  sel.SelectFeatures filter, esriSelectionResultNew, False    '选中满足条件的要素
  mxDoc.ActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing    '绘出选中的要素
  Set selEvents = mxDoc.FocusMap    '???
  selEvents.SelectionChanged    '通知系统选择已经改变了

End Sub

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?