阅读:2026回复:4
[求助]如何获得selectfeature工具选择的图元
问个问题,在AE中,我在toolbarcontrol中添加了selectfeature工具,现在我想获得用这个工具选择的图元,即:myfeature=所选的图元,该怎么写呀??
|
|
1楼#
发布于:2006-06-24 10:55
<P>定义个要素集合 ienumfeature,名字不知道有没写错:)</P>
<P>然后把要素集合=map.selection,然后myfeature=enumfeature.next</P> <img src="images/post/smile/dvbbs/em07.gif" /> |
|
|
2楼#
发布于:2006-07-02 11:11
<P>map好象没有selection这个属性啊</P>
<P>我也想知道怎么得到的,gis说具体一点哇</P><img src="images/post/smile/dvbbs/em02.gif" /><img src="images/post/smile/dvbbs/em02.gif" /> |
|
3楼#
发布于:2006-07-03 11:41
FeatureSelection
|
|
4楼#
发布于:2006-07-03 15:51
<P><FONT color=#008000>楼上说的没错,你看看下面两个例子,应该有点帮助</FONT></P>
<P>Public Sub LoopThruSelection()<BR> Dim pDoc As IMxDocument<BR> Dim pMap As IMap<BR> Dim pEnumFeat As IEnumFeature<BR> Dim pFeat As IFeature<BR> <BR> Set pDoc = ThisDocument<BR> Set pMap = pDoc.FocusMap<BR> Set pEnumFeat = pMap.FeatureSelection<BR> Set pFeat = pEnumFeat.Next<BR> Do While (Not pFeat Is Nothing)<BR> Debug.Print pFeat.Value(pFeat.Fields.FindField("Name"))<BR> Set pFeat = pEnumFeat.Next<BR> Loop<BR>End Sub<BR></P> <P><FONT color=#008000></FONT> </P> <P><FONT color=#008000></FONT> </P> <P><FONT color=#008000>'This helper object enumerates the features of a single</FONT><BR><CODE><FONT color=#008000>'selection set. Create on the default interface must be</FONT></CODE><BR><CODE><FONT color=#008000>'called before calling Next or Reset.</FONT></CODE><BR><BR><CODE><FONT color=#0000ff>Option Explicit<BR><BR>Implements</FONT></CODE> IEnumFeature<BR><BR><CODE><FONT color=#0000ff>Private</FONT></CODE> m_pSelectionSet <CODE><FONT color=#0000ff>As</FONT></CODE> ISelectionSet<BR><CODE><FONT color=#0000ff>Private</FONT></CODE> m_pFeatureCursor <CODE><FONT color=#0000ff>As</FONT></CODE> IFeatureCursor<BR><BR><CODE><FONT color=#0000ff>Private Function</FONT></CODE> IEnumFeature_Next() <CODE><FONT color=#0000ff>As</FONT></CODE> IFeature<BR> <CODE><FONT color=#008000>'Make sure Create has been called</FONT></CODE><BR> <CODE><FONT color=#0000ff>If</FONT></CODE> m_pFeatureCursor <CODE><FONT color=#0000ff>Is Nothing Then</FONT></CODE> ReturnError<BR> <CODE><FONT color=#0000ff>Set</FONT></CODE> IEnumFeature_Next = m_pFeatureCursor.NextFeature<BR><CODE><FONT color=#0000ff>End Function<BR><BR>Private Sub</FONT></CODE> IEnumFeature_Reset()<BR> <CODE><FONT color=#008000>'Make sure Create has been called</FONT></CODE><BR> <CODE><FONT color=#0000ff>If</FONT></CODE> m_pFeatureCursor <CODE><FONT color=#0000ff>Is Nothing Then</FONT></CODE> ReturnError<BR> m_pSelectionSet.Search <CODE><FONT color=#0000ff>Nothing</FONT></CODE>, <CODE><FONT color=#0000ff>False</FONT></CODE>, m_pFeatureCursor<BR><CODE><FONT color=#0000ff>End Sub<BR><BR>Public Sub</FONT></CODE> Create(pSelectionSet <CODE><FONT color=#0000ff>As</FONT></CODE> ISelectionSet)<BR> <CODE><FONT color=#008000>'Get a cursor from the selection set.</FONT></CODE><BR> <CODE><FONT color=#008000>'Don't assume the selection set is from a feature class.</FONT></CODE><BR> <CODE><FONT color=#008000>'Use an ICursor instead and check its type.</FONT></CODE><BR> <CODE><FONT color=#0000ff>Dim</FONT></CODE> pCursor <CODE><FONT color=#0000ff>As</FONT></CODE> ICursor<BR> <CODE><FONT color=#0000ff>Set</FONT></CODE> m_pSelectionSet = pSelectionSet<BR> m_pSelectionSet.Search <CODE><FONT color=#0000ff>Nothing</FONT></CODE>, <CODE><FONT color=#0000ff>False</FONT></CODE>, pCursor<BR> <CODE><FONT color=#0000ff>If Not TypeOf</FONT></CODE> pCursor <CODE><FONT color=#0000ff>Is</FONT></CODE> IFeatureCursor <CODE><FONT color=#0000ff>Then</FONT></CODE> ReturnError<BR> <CODE><FONT color=#0000ff>Set</FONT></CODE> m_pFeatureCursor = pCursor<BR><CODE><FONT color=#0000ff>End Sub<BR><BR>Private Sub</FONT></CODE> ReturnError()<BR> Err.Raise vbObjectError + 513, "EnumFeatureClass", _<BR> "Create has not been called with a valid selection set."<BR><CODE><FONT color=#0000ff>End Sub</FONT></CODE><BR><BR></P> |
|
|