一、SelectionSet的成员
SelectionSet的3个主要成员:
1、Count:获取选择集中记录的总数。返回的是一个int值。
2、isEmpty:判断当前选择集是否为空。返回的是一个bool值。
3、item:获取成员对象 ID的列表。返回的是一组long值。
二、SelectionSet的3个主要方法:
1、Contains:确定指定映射成员中的记录是否在选择集中。
2、FromDictionary:通过字典来创建一个选择集对象。
3、ToDictionary:从选择集创建映射成员及其相应对象 ID 的字典。
获取选择对象集:
Dim pmap As Map = MapView.Active.Map
Dim sele As SelectionSet
If sele.IsEmpty = True ThenMsgBox("未选择要素.")Exit Sub
End If
Dim sel_zs As Long = sele.Count '返回选择要素的个数
Dim sel_lv As Dictionary(Of MapMember, List(Of Long)) = sele.ToDictionary()
对于sel_lv,采用以下三种方法可以枚举出键值对:
方法一:按字典元素遍历
Dim info As String = ""
‘遍历选择集字典
For Each singleKey As KeyValuePair(Of MapMember, List(Of Long)) In sel_lv‘获取当前图层名称info = singleKey.Key.ToStringDim plist As List(Of Long) = singleKey.Value‘遍历当前图层选择集的要素对象IDFor Each fa As Long In plistDim ojbid = fa ’获取对象IDNext
Next
方法二:按字典键遍历
For Each singleKey In sel_lv.Keysinfo = singleKey.ToStringDim plist As List(Of Long) = sel_lv(singleKey)For Each fa As Long In plistDim ojbid = faNext
Next
方法三:按字典元素遍历
Dim myDicEnum As IDictionaryEnumerator = sel_lv.GetEnumerator()
Dim kvp As KeyValuePair(Of MapMember, List(Of Long))
While myDicEnum.MoveNext()kvp = CType(myDicEnum.Current, KeyValuePair(Of MapMember, List(Of Long)))info = kvp.Key.ToStringDim plist As List(Of Long) = kvp.ValueFor Each fa As Long In plistDim ojbid = faNext
End While