how to check if selection set is null

how to check if selection set is null

Anonymous
Not applicable
1,325 Views
3 Replies
Message 1 of 4

how to check if selection set is null

Anonymous
Not applicable
how do you check if selection set is null? this is my code. it doesnt work... lol


Dim myDWG As ApplicationServices.Document
Dim myDB As DatabaseServices.Database
Dim myEd As EditorInput.Editor
Dim myPSR As EditorInput.PromptSelectionResult
Dim mySS As EditorInput.SelectionSet
Dim myFilter(0) As DatabaseServices.TypedValue
myFilter(0) = New DatabaseServices.TypedValue(DatabaseServices.DxfCode.BlockName, "aaa")
Dim mySF As New EditorInput.SelectionFilter(myFilter)
myDWG = ApplicationServices.Application.DocumentManager.MdiActiveDocument
myDB = myDWG.Database
myEd = myDWG.Editor
myPSR = myEd.SelectAll(mySF)
mySS = myPSR.Value

---> this line is messed up, how do you fix this? im getting error if selectionset is empty...
If mySS <> Nothing Then
MsgBox(mySS.Count)
End If


Thanks....
0 Likes
1,326 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
wrote in message news:6366478@discussion.autodesk.com...
how do you check if selection set is null? this is my code. it doesnt
work... lol


---> this line is messed up, how do you fix this? im getting error if
selectionset is empty...
If mySS <> Nothing Then
MsgBox(mySS.Count)
End If


i have not enter you code, but just looking at its end gives me an idea that
you could try with:

If NOT myss IS nothing then
msgbox(myss.count)
end if

tell us did it worked that way?
i dont know if it can be not nothing but be 0?
if that is possable, then in that case there should be need to check that
also
0 Likes
Message 3 of 4

_gile
Consultant
Consultant
Hi,

'If NOT myss IS nothing then' is quite ugly...

Look at the Status property of PromptSelectionResult

a little C# sample:
{code}Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptSelectionResult psr = ed.GetSelection();
if (psr.Status == PromptStatus.OK)
Application.ShowAlertDialog(string.Format("{0} selected objects", psr.Value.GetObjectIds().Length));{code}


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 4

Anonymous
Not applicable
'If NOT myss IS nothing then' is quite ugly...


that is nicely noticed
my eyes just got glued to his direct question :" If mySS <> Nothing Then"
so i fail to see bigger picture :))
0 Likes