阅读:2713回复:8
AO中如何用VB显示选中的点
如题,在AO中选取的点,都想显示在图层上,用VB该怎么做?
|
|
|
1楼#
发布于:2008-03-07 19:24
<P>好东西呀</P>
|
|
2楼#
发布于:2004-07-17 18:57
试试看
|
|
3楼#
发布于:2004-07-16 15:22
谢谢,已经可以显示了!<img src="images/post/smile/dvbbs/em13.gif" />
|
|
|
4楼#
发布于: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编辑过]
|
|
|
5楼#
发布于: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> |
|
|
6楼#
发布于:2004-07-14 22:43
日
|
|
7楼#
发布于:2004-07-02 18:11
唉,看不明白......
|
|
|
8楼#
发布于: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> |
|
|