PickfirstSelectionSet Workaround

I found many posts about PickfirstSelectionSet not working properly, so
when I found a solution for myself I thought I should share it.
I use a lisp to launch my macro. The lisp I use to launch my macro
calls another lisp before activating my desired VBA Sub. The lisp
called senses if anything is currently selected. If anything is
selected, it calls a macro to set a global variable ("UseActive")
to true, and if nothing is selected it sets that variable to false.
Then it launches my Sub. When my sub runs it checks UseActive. If
UseActive is false the sub has the user select items; if UseActive is
true the sub uses ThisDrawing.ActiveSelectionSet (which contains the
items that were selected when the user started the command).
Lisp Routines:
(defun C:CurrentlySelected()
(if (ssget "I") (vl-vbarun "CurrentSelection") (vl-vbarun
(defun C:Mir2x ()
(vl-vbarun "mir2")
VBA Code:
Dim UseActive As Boolean
Public Sub NotCurrentSelection()
UseActive = False
End Sub
Public Sub CurrentSelection()
UseActive = True
End Sub
Public Sub SelectionSetRemove(SetName As String)
Dim a As AcadSelectionSet
For Each a In ThisDrawing.SelectionSets
If StrComp(a.Name, SetName, 1) = 0 Then
Exit For
End If
Next a
End Sub
Public Sub mir2()
Dim AttHolder()
Dim Curr_Obj As AcadObject
Dim Mird_Obj As AcadObject
Dim AttLocs()
Dim AttTemp(0 To 1)
Dim Mird_AttLocs()
Dim MiringTargets As AcadSelectionSet
On Error Resume Next
If UseActive = True Then
Set MiringTargets = ThisDrawing.ActiveSelectionSet
Set MiringTargets =
If Err.Number 0 Then
SelectionSetRemove ("ReservedUserSetForStarting")
Set MiringTargets =
End If
End If

And then on to the rest of my program.
Reply to
Loading thread data ...

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.