@_gile
OK So its sort of working now, it is filtering but it is now bypassing the second prompt. I turned your test1 into a function to return the objectid collection and run a for each on all of them. The problem I have is it now skips the second prompt and leaves the objects selected at the end of the command. Im sure its something simple stupid. 🙂
I belive I need to convert the objectID collection to a selection set. Just not sure how to do that.
Fucntion:
Private Function FilterDetails(ByVal acPromptSelectionResultsAll As PromptSelectionResult)
Dim ids = New ObjectIdCollection()
Using acTranaction As Transaction = Active.Database.TransactionManager.StartTransaction()
For Each id In acPromptSelectionResultsAll.Value.GetObjectIds()
Dim br = CType(acTranaction.GetObject(id, OpenMode.ForRead), BlockReference)
Dim effectiveName As String = (CType(acTranaction.GetObject(br.DynamicBlockTableRecord, OpenMode.ForRead), BlockTableRecord)).Name
If Autodesk.AutoCAD.Internal.Utils.WcMatchEx(effectiveName, "*-SIGN-*", True) Then ids.Add(id)
Next
Dim selectedIds = New ObjectId(ids.Count - 1) {}
ids.CopyTo(selectedIds, 0)
acCurrentEditor.SetImpliedSelection(selectedIds)
acTranaction.Commit()
End Using
Return ids
End Function
Sub:
Public Sub SelectDetails()
Dim acPromptSelectionOptionsAll As PromptSelectionOptions = New PromptSelectionOptions()
Dim acSelectionFilterAll = New SelectionFilter({New TypedValue(0, "INSERT"), New TypedValue(2, "`*U*,*-SIGN-*")})
acPromptSelectionOptionsAll.MessageForAdding = "Please Select ALL Traffic Sign Details: "
acPromptSelectionOptionsAll.MessageForRemoval = "Select a Traffic Sign Detail to remove: "
Dim acPromptSelectionResultsAll As PromptSelectionResult = acCurrentEditor.GetSelection(acPromptSelectionOptionsAll, acSelectionFilterAll)
If acPromptSelectionResultsAll.Status = PromptStatus.OK Then
Dim acSelectionSetAllFiltered = FilterDetails(acPromptSelectionResultsAll)
Dim acPromptSelectionOptionsExisting As PromptSelectionOptions = New PromptSelectionOptions()
Dim acSelectionFilterExisting = New SelectionFilter({New TypedValue(0, "INSERT"), New TypedValue(2, "`*U*,*-SIGN-*")})
acPromptSelectionOptionsExisting.MessageForAdding = "Please Select the Traffic Sign Details to be Exiting: "
acPromptSelectionOptionsExisting.MessageForRemoval = "Select a Traffic Sign Detail to remove: "
Dim acPromptSelectionResultsExisting As PromptSelectionResult = acCurrentEditor.GetSelection(acPromptSelectionOptionsExisting, acSelectionFilterExisting)
If acPromptSelectionResultsExisting.Status = PromptStatus.OK Then
Dim acSelectionSetExistingFiltered = FilterDetails(acPromptSelectionResultsExisting)
CreateDetailLayer("G-DTLS-TRAF-SIGN-EXST", 253, "G04030(253)", "Details: Traffic Sign Details - Existing")
CreateDetailLayer("G-DTLS-TRAF-SIGN-PROP", 3, "B025(11)", "Details: Traffic Sign Details - Proposed")
For Each acSelectedObjectId In acSelectionSetAllFiltered
If Not IsDBNull(acSelectedObjectId) Then
SetDetailState(acSelectedObjectId, "G-DTLS-TRAF-SIGN-PROP")
End If
Next
For Each acSelectedObjectId In acSelectionSetExistingFiltered
If Not IsDBNull(acSelectedObjectId) Then
SetDetailState(acSelectedObjectId, "G-DTLS-TRAF-SIGN-EXST")
End If
Next
Else
CreateDetailLayer("G-DTLS-TRAF-SIGN-PROP", 3, "B025(11)", "Details: Traffic Sign Details - Proposed")
For Each acSelectedObject In acSelectionSetAllFiltered
If Not IsDBNull(acSelectedObject) Then
SetDetailState(acSelectedObject, "G-DTLS-TRAF-SIGN-PROP")
End If
Next
End If
FreezeDetailGridLayers()
End If
acCurrentEditor.Regen()
End Sub
It appears to be doing the following to all selected:
For Each acSelectedObjectId In acSelectionSetExistingFiltered
If Not IsDBNull(acSelectedObjectId) Then
SetDetailState(acSelectedObjectId, "G-DTLS-TRAF-SIGN-EXST")
End If
Next