Reg. Selection Set Error

Reg. Selection Set Error

Anonymous
Not applicable
923 Views
2 Replies
Message 1 of 3

Reg. Selection Set Error

Anonymous
Not applicable

Hi,

I want to select all circle form the active drawing so I have found the code as mentioned below from "acadauto.chm" which is used for Active VBA reference programming.

' Create the selection set
Dim ssetObj As AcadSelectionSet
ssetObj = objAcadDoc.SelectionSets.Add("SSET")

Dim gpCode(0) As Integer
Dim dataValue(0) As Object
gpCode(0) = 0
dataValue(0) = "Circle"

Dim groupCode As Object, dataCode As Object
groupCode = gpCode
dataCode = dataValue

ssetObj.Select(AcSelect.acSelectionSetAll, , , groupCode, dataCode)

and I am getting the error as mentioned below : 2nd & 3rd arguments were optional so I don't want that
Invalid argument FilterType in Select

Can anyone tell me what is the wrong with this code ?

0 Likes
924 Views
2 Replies
Replies (2)
Message 2 of 3

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

are you really running AutoCAD-VBA? (and not VB.NET?)
Because in VBA you have a more problems like using "Variant" instead of "Object" in your lines, using the syntax "Set ssetObj = ..." instead of just "ssetObj = ..."

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 3 of 3

Anonymous
Not applicable

try this

option explicit

Sub CircleSelect()

Dim ssetObj As AcadSelectionSet

On Error Resume Next
Set ssetObj = ThisDrawing.SelectionSets.Item("SSET")
If Err Then Set ssetObj = ThisDrawing.SelectionSets.Add("SSET")
On Error GoTo 0
ssetObj.Clear

Dim gpCode(0) As Integer
Dim dataValue(0) As Variant
gpCode(0) = 0
dataValue(0) = "Circle"

Dim groupCode As Variant, dataCode As Variant
groupCode = gpCode
dataCode = dataValue

ssetObj.Select AcSelect.acSelectionSetAll, , , groupCode, dataCode

MsgBox ssetObj.Count

End Sub

 

bye