千山暮雪
路人甲
路人甲
  • 注册日期2004-06-25
  • 发帖数87
  • QQ
  • 铜币352枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:2712回复:8

AO中如何用VB显示选中的点

楼主#
更多 发布于:2004-07-02 16:38
  如题,在AO中选取的点,都想显示在图层上,用VB该怎么做?
喜欢0 评分0
你来自北京周口, 我来自云南元谋, 我拉着你毛茸茸的小手, 轻轻的咬上一口, 啊, 是爱情让我们直立行走!
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
1楼#
发布于:2004-07-02 17:24
<P>你可以看看例子中带的选择的例子了,</P><P>'This example demonstrates how to use <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Select</FONT></P><P>Sub SelectTopologyGraph()
Dim pMxDoc As IMxDocument
Dim pTopology As ITopology
Dim pTopologyLayer As ITopologyLayer
Dim pTopologyGraph As ITopologyGraph
Dim bsel As Boolean
Dim pTopologyEdge As ITopologyEdge
Dim pEnumTopologyEdge As IEnumTopologyEdge
Set pMxDoc = ThisDocument
'Assume that there is a topology layer in position 0 in TOC
If Not TypeOf pMxDoc.FocusMap.Layer(0) Is ITopologyLayer Then Exit Sub
Set pTopologyLayer = pMxDoc.FocusMap.Layer(0)
Set pTopology = pTopologyLayer.Topology
Set pTopologyGraph = pTopology.Cache
pTopologyGraph.Build pMxDoc.ActiveView.Extent, False
Set pEnumTopologyEdge = pTopologyGraph.Edges
Set pTopologyEdge = pEnumTopologyEdge.Next
bsel = pTopologyGraph.<FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Select</FONT>(esriTopologySelectionResultNew, pTopologyEdge)
Debug.Print "esriTopologySelectionResultNew"
Debug.Print "Is the <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> changed : " ; bsel
Debug.Print "<FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Selection</FONT> count : " ; pTopologyGraph.SelectionCount(esriTopologyEdge)
'esriTopologySelectionResultNew
'Is the <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> changed : True
'Selection count : 1
Set pTopologyEdge = pEnumTopologyEdge.Next
bsel = pTopologyGraph.<FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Select</FONT>(esriTopologySelectionResultAdd, pTopologyEdge)
Debug.Print "esriTopologySelectionResultAdd"
Debug.Print "Is the <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> changed : " ; bsel
Debug.Print "<FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Selection</FONT> count : " ; pTopologyGraph.SelectionCount(esriTopologyEdge)
'esriTopologySelectionResultAdd
'Is the <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> changed : True
'Selection count : 2
bsel = pTopologyGraph.<FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Select</FONT>(esriTopologySelectionResultSubtract, pTopologyEdge)
Debug.Print "esriTopologySelectionResultSubtract"
Debug.Print "Is the <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> changed : " ; bsel
Debug.Print "<FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Selection</FONT> count : " ; pTopologyGraph.SelectionCount(esriTopologyEdge)
'esriTopologySelectionResultSubtract
'Is the <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> changed : True
'Selection count : 1
bsel = pTopologyGraph.<FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Select</FONT>(esriTopologySelectionResultXOR, pTopologyEdge)
Debug.Print "esriTopologySelectionResultXOR"
Debug.Print "Is the <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> changed : " ; bsel
Debug.Print "<FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Selection</FONT> count : " ; pTopologyGraph.SelectionCount(esriTopologyEdge)
'esriTopologySelectionResultXOR : <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>Select</FONT>/Unselect the element depending on its <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> state
'Is the <FONT style="BACKGROUND-COLOR: #0a246a" color=#ffffff>selection</FONT> changed : True
'Selection count : 2
</P>
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
千山暮雪
路人甲
路人甲
  • 注册日期2004-06-25
  • 发帖数87
  • QQ
  • 铜币352枚
  • 威望0点
  • 贡献值0点
  • 银元0个
2楼#
发布于:2004-07-02 18:11
唉,看不明白......
你来自北京周口, 我来自云南元谋, 我拉着你毛茸茸的小手, 轻轻的咬上一口, 啊, 是爱情让我们直立行走!
举报 回复(0) 喜欢(0)     评分
runner
路人甲
路人甲
  • 注册日期2004-07-14
  • 发帖数46
  • QQ
  • 铜币101枚
  • 威望0点
  • 贡献值0点
  • 银元0个
3楼#
发布于:2004-07-14 22:43
举报 回复(0) 喜欢(0)     评分
千山暮雪
路人甲
路人甲
  • 注册日期2004-06-25
  • 发帖数87
  • QQ
  • 铜币352枚
  • 威望0点
  • 贡献值0点
  • 银元0个
4楼#
发布于:2004-07-16 11:59
'查找显示点
  Dim pMap As IMap
  Dim pLayer As ILayer
  Dim pFeatureLayer As IFeatureLayer
  Dim sQuery As String
  
  sQuery = "OBJECTID>200 and OBJECTID<300"
  Set pMap = MapGN.Map
  Set pLayer = pMap.Layer(0)
  Set pFeatureLayer = pLayer
<P>  Dim pQuery As IQueryFilter
  Set pQuery = New QueryFilter
  
  pQuery.SubFields = "OBJECTID"
  pQuery.WhereClause = sQuery
    
  Dim pFeatureCursor As IFeatureCursor
  Set pFeatureCursor = pFeatureLayer.Search(pQuery, False)
  
  MapGN.Refresh</P><P>怎么什么都没有显示,哪点出问题了?</P>
你来自北京周口, 我来自云南元谋, 我拉着你毛茸茸的小手, 轻轻的咬上一口, 啊, 是爱情让我们直立行走!
举报 回复(0) 喜欢(0)     评分
gis
gis
管理员
管理员
  • 注册日期2003-07-16
  • 发帖数15951
  • QQ
  • 铜币25345枚
  • 威望15368点
  • 贡献值0点
  • 银元0个
  • GIS帝国居民
  • 帝国沙发管家
  • GIS帝国明星
  • GIS帝国铁杆
5楼#
发布于:2004-07-16 12:07
<P>还是例子里的东西</P>
<P  align=left><B>Description:</B>

This sample shows two possible methods for doing an attribute seleciton. The first script uses the 'Select By Attributes' dialog enabling the client to enter a specific attribute query. This macro sets a default expression that can be cleared or modified in the dialog. The second script creates an attribute query using a QueryFilter and performs the selection manually, without the aid of the 'Select By Attributes' dialog.

<B>How to use:</B> <p></p></P>
<OL type=1>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; tab-stops: list 36.0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">Paste the code into VBA. <p></p></LI>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; tab-stops: list 36.0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">Modify the default expression if desired. <p></p></LI>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; tab-stops: list 36.0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">Load one or more feature layers. <p></p></LI>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; tab-stops: list 36.0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">From the Macros dialog, run the AttributeQuery macro. <p></p></LI>
<LI class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; tab-stops: list 36.0pt; mso-list: l0 level1 lfo1; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto">Create a new query in the query builder and hit apply.<p></p></LI></OL>
<P  align=left>Public Sub AttributeQuery()<p></p></P>
<P  align=left>  Dim pQueryAttributes As IQueryAttributes<p></p></P>
<P  align=left>  'Create a new Query Attribute Dialog and set<p></p></P>
<P  align=left>  'some necessary properties before launching it<p></p></P>
<P  align=left>  Set pQueryAttributes = New QueryAttributes<p></p></P>
<P  align=left>  Set pQueryAttributes.Application = Application<p></p></P>
<P  align=left>  pQueryAttributes.SelectFeaturesInLayerOnOK = True<p></p></P>
<P  align=left>  'Provide a default expression if desired<p></p></P>
<P  align=left>  pQueryAttributes.Expression = """NAME"" = 'Halifax'"<p></p></P>
<P  align=left>  'Lauch the dialog<p></p></P>
<P  align=left>  pQueryAttributes.DoModal Application.hWnd<p></p></P>
<P  align=left>End Sub<p></p></P>
<P  align=left><p> </p></P>
<P  align=left>Here is a second approach the doesn't use the 'Select By Attributes' dialog.<p></p></P>
<P  align=left><p> </p></P>
<P  align=left>Public Sub SelectMapFeatures()<p></p></P>
<P  align=left>  Dim pMxDoc As IMxDocument<p></p></P>
<P  align=left>  Dim pMap As IMap<p></p></P>
<P  align=left>  Dim pActiveView As IActiveView<p></p></P>
<P  align=left>  Dim pFeatureLayer As IFeatureLayer<p></p></P>
<P  align=left>  Dim pFeatureSelection As IFeatureSelection<p></p></P>
<P  align=left>  Dim pQueryFilter As IQueryFilter<p></p></P>
<P  align=left>  <p></p></P>
<P  align=left>  Set pMxDoc = Application.Document<p></p></P>
<P  align=left>  Set pMap = pMxDoc.FocusMap<p></p></P>
<P  align=left>  Set pActiveView = pMap<p></p></P>
<P  align=left>  <p></p></P>
<P  align=left>  'For simplicity sake let's use the first layer in the map<p></p></P>
<P  align=left>  If Not TypeOf pMap.Layer(0) Is IFeatureLayer Then Exit Sub<p></p></P>
<P  align=left>  Set pFeatureLayer = pMap.Layer(0)<p></p></P>
<P  align=left>  Set pFeatureSelection = pFeatureLayer 'QI<p></p></P>
<P  align=left>  <p></p></P>
<P  align=left>  'Create the query filter<p></p></P>
<P  align=left>  Set pQueryFilter = New QueryFilter<p></p></P>
<P  align=left>  pQueryFilter.WhereClause = "NAME = 'Nova Scotia'"<p></p></P>
<P  align=left>  <p></p></P>
<P  align=left>  'Invalidate only the selection cache<p></p></P>
<P  align=left>  'Flag the original selection<p></p></P>
<P  align=left>  pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing<p></p></P>
<P  align=left>  'Perform the selection<p></p></P>
<P  align=left>  pFeatureSelection.SelectFeatures pQueryFilter, esriSelectionResultNew, False<p></p></P>
<P  align=left>  'Flag the new selection<p></p></P>
<P  align=left>  pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing<p></p></P>
<P  align=left>  <p></p></P>
<P  align=left>End Sub<p></p></P>
<P ><p><FONT face="Times New Roman" size=3> </FONT></p></P>

[此贴子已经被作者于2004-7-16 12:07:52编辑过]
GIS麦田守望者,期待与您交流。
举报 回复(0) 喜欢(0)     评分
千山暮雪
路人甲
路人甲
  • 注册日期2004-06-25
  • 发帖数87
  • QQ
  • 铜币352枚
  • 威望0点
  • 贡献值0点
  • 银元0个
6楼#
发布于:2004-07-16 15:22
谢谢,已经可以显示了!<img src="images/post/smile/dvbbs/em13.gif" />
你来自北京周口, 我来自云南元谋, 我拉着你毛茸茸的小手, 轻轻的咬上一口, 啊, 是爱情让我们直立行走!
举报 回复(0) 喜欢(0)     评分
pearlstar
路人甲
路人甲
  • 注册日期2004-07-11
  • 发帖数92
  • QQ
  • 铜币160枚
  • 威望0点
  • 贡献值0点
  • 银元0个
7楼#
发布于:2004-07-17 18:57
试试看
举报 回复(0) 喜欢(0)     评分
ienown
路人甲
路人甲
  • 注册日期2006-11-14
  • 发帖数23
  • QQ6805791
  • 铜币149枚
  • 威望0点
  • 贡献值0点
  • 银元0个
8楼#
发布于:2008-03-07 19:24
<P>好东西呀</P>
举报 回复(0) 喜欢(0)     评分
游客

返回顶部