In this case I wanted to select some HSBcad object, but the general goal was to create some functions wich I can use in more cases.
Beneath are the functions I created in VB.Net 2003
#Region " Selections Sets "
Friend Function SelectionSet_CreateWindow(ByVal Name As String, ByVal ObjectName As String) As AcadSelectionSet
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim SSObj As AcadSelectionSet
Try
acadApp = CType(GetObject(, AutoCadApplicatie), AcadApplication)
acadApp.Visible = True
acadDoc = acadApp.ActiveDocument
acadDoc.Application.Visible = True
SSObj = acadDoc.SelectionSets.Add(Name)
Dim FilterType() As Int16 = {0}
Dim FilterData() As Object = {ObjectName}
SSObj.SelectOnScreen(FilterType, FilterData)
Return SSObj
Autodesk.AutoCAD.ApplicationServices.CommandLinePrompts.Message(vbCrLf & SSObj.Count & " Objects selected" + vbCrLf)
Catch ex As Exception
MessageBox.Show(ex.ToString)
Return Nothing
End Try
End Function
Friend Function SelectionSet_CreateAll(ByVal Name As String, ByVal ObjectName As String) As AcadSelectionSet
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim SSObj As AcadSelectionSet
Try
acadApp = CType(GetObject(, AutoCadApplicatie), AcadApplication)
acadApp.Visible = True
acadDoc = acadApp.ActiveDocument
acadDoc.Application.Visible = True
SSObj = acadDoc.SelectionSets.Add(Name)
Dim FilterType() As Int16 = {0}
Dim FilterData() As Object = {ObjectName}
SSObj.Select(AcSelect.acSelectionSetAll, , , FilterType, FilterData)
Return SSObj
Autodesk.AutoCAD.ApplicationServices.CommandLinePrompts.Message(vbCrLf & SSObj.Count & " Objects selected" + vbCrLf)
Catch ex As Exception
MessageBox.Show(ex.ToString)
Return Nothing
End Try
End Function
Friend Function SelectionSet_Delete(ByVal Name As String) As Boolean
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument
Dim Obj As AcadSelectionSet
Dim Found As Boolean = False
Try
acadApp = CType(GetObject(, AutoCadApplicatie), AcadApplication)
acadApp.Visible = True
acadDoc = acadApp.ActiveDocument
acadDoc.Application.Visible = True
For Each Obj In acadDoc.SelectionSets
If Obj.Name = Name Then Found = True
Next
If Found = True Then acadDoc.SelectionSets.Item(Name).Delete()
Return True
Catch ex As Exception
MessageBox.Show(ex.ToString)
Return False
End Try
End Function
#End Region