Subtracting one selection set from another?

Subtracting one selection set from another?

Anonymous
Not applicable
144 Views
2 Replies
Message 1 of 3

Subtracting one selection set from another?

Anonymous
Not applicable
I'm trying to delete everything in a drawing except for whatever is inside
of an area defined by a windowl, but run into the following problem:

' Create a new selection set with everything in it
Dim ssetObj As AcadSelectionSet
Set ssetObj = acadDoc.SelectionSets.Add("SSET")
Dim mode As Integer
mode = acSelectionSetAll
ssetObj.Select mode

' Create another selection set of the stuff that I want to keep
Dim ssetObjKeep As AcadSelectionSet
Set ssetObjKeep = acadDoc.SelectionSets.Add("KEEP")
mode = acSelectionSetCrossing
Dim corner1(0 To 2) As Double
Dim corner2(0 To 2) As Double
corner1(0) = 0.1938: corner1(1) = 0.21: corner1(2) = 0
corner2(0) = -0.1938: corner2(1) = -0.3025: corner2(2) = 0
ssetObjKeep.Select mode, corner1, corner2

' Subtract the "keeper" set from the main set
' The problem is with this next line. It says "invalid argument"
ssetObj.RemoveItems ssetObjKeep

' Delete everything in the main selection set
ssetObj.Erase

Is there an easier approach to this problem?

Thanks,

John S.
0 Likes
145 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
RemoveItems expects an array of AcadEntity objects, not an AcadSelectionSet.
Here's a helper routine for you. Include this in your project and change
this line of code:
ssetObj.RemoveItems ssetObjKeep

to this:
ssetObj.RemoveItems ssArray(ssetObjKeep)

Here's the ssArray function:

Public Function ssArray(ss As AcadSelectionSet)

Dim retVal() As AcadEntity, i As Long

ReDim retVal(0 To ss.Count - 1)

For i = 0 To ss.Count - 1
Set retVal(i) = ss.Item(i)
Next

ssArray = retVal

End Function

--
Visit AcadXtreme for a chance to win a copy of AutoCAD LT 2000
Contest ends 5/26/00
http://www.acadx.com

"John Sauber" wrote in message
news:ef137c0.-1@WebX.SaUCah8kaAW...
> I'm trying to delete everything in a drawing except for whatever is inside
> of an area defined by a windowl, but run into the following problem:
>
> ' Create a new selection set with everything in it
> Dim ssetObj As AcadSelectionSet
> Set ssetObj = acadDoc.SelectionSets.Add("SSET")
> Dim mode As Integer
> mode = acSelectionSetAll
> ssetObj.Select mode
>
> ' Create another selection set of the stuff that I want to keep
> Dim ssetObjKeep As AcadSelectionSet
> Set ssetObjKeep = acadDoc.SelectionSets.Add("KEEP")
> mode = acSelectionSetCrossing
> Dim corner1(0 To 2) As Double
> Dim corner2(0 To 2) As Double
> corner1(0) = 0.1938: corner1(1) = 0.21: corner1(2) = 0
> corner2(0) = -0.1938: corner2(1) = -0.3025: corner2(2) = 0
> ssetObjKeep.Select mode, corner1, corner2
>
> ' Subtract the "keeper" set from the main set
> ' The problem is with this next line. It says "invalid argument"
> ssetObj.RemoveItems ssetObjKeep
>
> ' Delete everything in the main selection set
> ssetObj.Erase
>
> Is there an easier approach to this problem?
>
> Thanks,
>
> John S.
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
That did the trick. Thanks much. Sorry for the duplicate posting. --
js

Frank Oquendo wrote in message
news:ef137c0.0@WebX.SaUCah8kaAW...
> RemoveItems expects an array of AcadEntity objects, not an
AcadSelectionSet.
> Here's a helper routine for you. Include this in your project and change
> this line of code:
> ssetObj.RemoveItems ssetObjKeep
>
> to this:
> ssetObj.RemoveItems ssArray(ssetObjKeep)
>
> Here's the ssArray function:
>
> Public Function ssArray(ss As AcadSelectionSet)
>
> Dim retVal() As AcadEntity, i As Long
>
> ReDim retVal(0 To ss.Count - 1)
>
> For i = 0 To ss.Count - 1
> Set retVal(i) = ss.Item(i)
> Next
>
> ssArray = retVal
>
> End Function
>
> --
> Visit AcadXtreme for a chance to win a copy of AutoCAD LT 2000
> Contest ends 5/26/00
> http://www.acadx.com
>
> "John Sauber" wrote in message
> news:ef137c0.-1@WebX.SaUCah8kaAW...
> > I'm trying to delete everything in a drawing except for whatever is
inside
> > of an area defined by a windowl, but run into the following problem:
> >
> > ' Create a new selection set with everything in it
> > Dim ssetObj As AcadSelectionSet
> > Set ssetObj = acadDoc.SelectionSets.Add("SSET")
> > Dim mode As Integer
> > mode = acSelectionSetAll
> > ssetObj.Select mode
> >
> > ' Create another selection set of the stuff that I want to keep
> > Dim ssetObjKeep As AcadSelectionSet
> > Set ssetObjKeep = acadDoc.SelectionSets.Add("KEEP")
> > mode = acSelectionSetCrossing
> > Dim corner1(0 To 2) As Double
> > Dim corner2(0 To 2) As Double
> > corner1(0) = 0.1938: corner1(1) = 0.21: corner1(2) = 0
> > corner2(0) = -0.1938: corner2(1) = -0.3025: corner2(2) = 0
> > ssetObjKeep.Select mode, corner1, corner2
> >
> > ' Subtract the "keeper" set from the main set
> > ' The problem is with this next line. It says "invalid argument"
> > ssetObj.RemoveItems ssetObjKeep
> >
> > ' Delete everything in the main selection set
> > ssetObj.Erase
> >
> > Is there an easier approach to this problem?
> >
> > Thanks,
> >
> > John S.
> >
>
0 Likes