Remove Items from selection Set (Novice Question)

Remove Items from selection Set (Novice Question)

Anonymous
Not applicable
3,372 Views
4 Replies
Message 1 of 5

Remove Items from selection Set (Novice Question)

Anonymous
Not applicable
Ok, can someone please help me here!!!

Just as an exercise, I am trying to create a Selection Set, and then Remove all Items from the set. Everything seems to work fine until I execute the RemoveItems Method. When I do, I get a "Invalid argument Items in RemoveItems" error.

Can anybody tell me what I am doing wrong here???


Public Sub ChangePath()

Dim SelRefs As AcadSelectionSet
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant

Set SelRefs = ThisDrawing.SelectionSets.Add("SEL_REFS")

FilterType(0) = 0
FilterData(0) = "INSERT"

SelRefs.Select acSelectionSetAll, , , FilterType, FilterData

ReDim entObj(0 To SelRefs.Count - 1) As Variant
Dim i As Integer

For i = 0 To SelRefs.Count - 1

Set entObj(i) = SelRefs.Item(i)

Next i

SelRefs.RemoveItems entObj

SelRefs.Delete

End Sub
0 Likes
3,373 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
RemoveItems requires an array of objects, even if it is a single object.

--
R. Robert Bell


wrote in message news:5059242@discussion.autodesk.com...
Ok, can someone please help me here!!!

Just as an exercise, I am trying to create a Selection Set, and then Remove
all Items from the set. Everything seems to work fine until I execute the
RemoveItems Method. When I do, I get a "Invalid argument Items in
RemoveItems" error.

Can anybody tell me what I am doing wrong here???


Public Sub ChangePath()

Dim SelRefs As AcadSelectionSet
Dim FilterType(0) As Integer
Dim FilterData(0) As Variant

Set SelRefs = ThisDrawing.SelectionSets.Add("SEL_REFS")

FilterType(0) = 0
FilterData(0) = "INSERT"

SelRefs.Select acSelectionSetAll, , , FilterType, FilterData

ReDim entObj(0 To SelRefs.Count - 1) As Variant
Dim i As Integer

For i = 0 To SelRefs.Count - 1

Set entObj(i) = SelRefs.Item(i)

Next i

SelRefs.RemoveItems entObj

SelRefs.Delete

End Sub
0 Likes
Message 3 of 5

Anonymous
Not applicable
I thought I was creating an array by looping thru and setting entObj(i) each time thru. So I assume this is not considered an array? Or am I referring to it wrong when trying to delete it?

Also, I saw "ReDim" in an example, that is why I used it to declare "entObj(0 To SelRefs.Count - 1)". If I use "Dim" it gives me an error. Is ReDim to be used just as it sounds? To redeclare something if it has already been declared?

Any suggestions on beginner tutorials?

Jon
0 Likes
Message 4 of 5

Anonymous
Not applicable
your array needs to be an 'AcadEntity'
not 'Variant' datatype

--
gl - Paul
wrote in message news:5059404@discussion.autodesk.com...
I thought I was creating an array by looping thru and setting entObj(i) each
time thru. So I assume this is not considered an array? Or am I referring to
it wrong when trying to delete it?

Also, I saw "ReDim" in an example, that is why I used it to declare
"entObj(0 To SelRefs.Count - 1)". If I use "Dim" it gives me an error. Is
ReDim to be used just as it sounds? To redeclare something if it has already
been declared?

Any suggestions on beginner tutorials?

Jon
0 Likes
Message 5 of 5

fxcastil
Advocate
Advocate
Albert,

A good AutoCAD VBA book is Autocad 200x by Joe Stuphin

a few of my favorite links below

http://www.afralisp.co.za/index.htm

http://msdn.microsoft.com/isv/technology/vba/default.aspx

http://visualbasic.about.com/cs/programmingvba/?iam=metaresults&terms=developer+vba

http://www.vbaccelerator.com/home/index.asp

http://www.visualbasicforum.com

http://www.mrexcel.com/board2/index.php?sid=0ebc52e66ae9c23c13f36a4941084890


Fred C
0 Likes