Issue
I’m migrating my VBA code to VB.NET and getting an exception in the AcadSelectionSet.Select(). What am I doing wrong?
Solution
This is a sample how to select all entities on a given layer:
Dim FilterType(0) As Int16 ' IMPORTANT: The type must be Int16, ' otherwise you'll get an exception! Dim FilterData(0) As Object Dim objSS As Autodesk.AutoCAD.Interop.AcadSelectionSet = Nothing Try FilterType(0) = 8 ' Will select all entities with the given Layer name FilterData(0) = "MyLayer" ' It's the layer name Dim acadApp As Autodesk.AutoCAD.Interop.AcadApplication = _ Autodesk.AutoCAD.ApplicationServices. Application.AcadApplication objSS = acadApp.Documents.Application.ActiveDocument. SelectionSets.Add("MySet") objSS.Clear() objSS.Select( Autodesk.AutoCAD.Interop.Common.AcSelect.acSelectionSetAll, _ , , FilterType, FilterData) objSS.Highlight(True) MsgBox(objSS.Count & " entities selected.") Catch ex As Exception MsgBox(ex.Message) Finally If Not objSS Is Nothing Then objSS.Delete() End If End Try

Leave a Reply