Message 1 of 5
Selection set error; key not found

Not applicable
09-13-2002
01:00 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone, I am trying to make a selection set of external references by using block collection. It does add external reference to selection set but only on alternate instances and causes an error "-2145386476; Key not found" on alternate instances. Any suggestion would be appreciated. Here is the routine I am using to create and populate the selection set. Thanks.
Private Sub SetXRefFlName()
Dim oSS As AcadSelectionSet
Dim intCode(0 To 1) As Integer
Dim strCodeVal(0 To 1) As Variant
Dim grpCode As Variant
Dim grpCodeVal As Variant
Dim oBlk As AcadBlock
Dim oXRef As AcadExternalReference
Dim xFlPath As String
Dim xFlName As String
On Error Resume Next
'Create a file manager object
Call CreateFileMgr
'Set SS object
Set oSS = ThisDrawing.SelectionSets.Item("SSXRef")
If oSS Is Nothing Then
Set oSS = ThisDrawing.SelectionSets.Add("SSXRef")
If oSS Is Nothing Then
MsgBox "unable to add selection set 'SSXRef'"
Exit Sub
End If
End If
'Set a code and value for a Xref blocks to populate selection set
intCode(0) = 0: strCodeVal(0) = "INSERT"
intCode(1) = 2
'Assign arrays to variant variables
grpCode = intCode
XRFls = ""
For Each oBlk In ThisDrawing.Blocks
If oBlk.IsXRef Then
strCodeVal(1) = oBlk.Name
grpCodeVal = strCodeVal
'Clear XRef selection set
oSS.Clear
'Add all objects on the layar selection set
oSS.Select acSelectionSetAll, , , grpCode, grpCodeVal
If Err Then
MsgBox Err.Number & ", " & Err.Description
Err.Clear
Exit Sub
End If
If oSS.Count > 0 Then
Set oXRef = oSS.Item(0)
xFlPath = oXRef.Path
xFlName = xFlMgr.GetFileName(xFlPath)
If XRFls <> "" Then
XRFls = XRFls & ","
End If
XRFls = XRFls & xFlName
End If
End If
Next
'Delete the XRef selection set
oSS.Delete
MsgBox XRFls
End Sub
Private Sub SetXRefFlName()
Dim oSS As AcadSelectionSet
Dim intCode(0 To 1) As Integer
Dim strCodeVal(0 To 1) As Variant
Dim grpCode As Variant
Dim grpCodeVal As Variant
Dim oBlk As AcadBlock
Dim oXRef As AcadExternalReference
Dim xFlPath As String
Dim xFlName As String
On Error Resume Next
'Create a file manager object
Call CreateFileMgr
'Set SS object
Set oSS = ThisDrawing.SelectionSets.Item("SSXRef")
If oSS Is Nothing Then
Set oSS = ThisDrawing.SelectionSets.Add("SSXRef")
If oSS Is Nothing Then
MsgBox "unable to add selection set 'SSXRef'"
Exit Sub
End If
End If
'Set a code and value for a Xref blocks to populate selection set
intCode(0) = 0: strCodeVal(0) = "INSERT"
intCode(1) = 2
'Assign arrays to variant variables
grpCode = intCode
XRFls = ""
For Each oBlk In ThisDrawing.Blocks
If oBlk.IsXRef Then
strCodeVal(1) = oBlk.Name
grpCodeVal = strCodeVal
'Clear XRef selection set
oSS.Clear
'Add all objects on the layar selection set
oSS.Select acSelectionSetAll, , , grpCode, grpCodeVal
If Err Then
MsgBox Err.Number & ", " & Err.Description
Err.Clear
Exit Sub
End If
If oSS.Count > 0 Then
Set oXRef = oSS.Item(0)
xFlPath = oXRef.Path
xFlName = xFlMgr.GetFileName(xFlPath)
If XRFls <> "" Then
XRFls = XRFls & ","
End If
XRFls = XRFls & xFlName
End If
End If
Next
'Delete the XRef selection set
oSS.Delete
MsgBox XRFls
End Sub