AddItems method example


Sub AddItems_Example()
' This example creates a selection set, and a line and circle objects.
' It then adds the objects to the selection set and clears the set.
    Dim ssetObj As AcadSelectionSet
    Dim i As Integer
    Dim lineObj As AcadLine
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    Dim circObj As AcadCircle
    Dim centerPt(0 To 2) As Double
    Dim dRadius As Double
    Dim ssetName
    ssetName = InputBox("Type a name for the selection set:")
    Set ssetObj = ThisDrawing.SelectionSets.Add(ssetName)
    ' Create a line object in model space
    startPoint(0) = 3: startPoint(1) = 1: startPoint(2) = 0
    endPoint(0) = 5: endPoint(1) = 5: endPoint(2) = 0
    Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
    ' Create a circle object in model space
    centerPt(0) = 3: centerPt(1) = 1: centerPt(2) = 0
    dRadius = 5
    Set circObj = ThisDrawing.ModelSpace.AddCircle(centerPt, dRadius)
    ' Collect the objects into an array of objects
    ' to be added to the selection set.
    ReDim ssobjs(0 To ThisDrawing.ModelSpace.Count - 1) As AcadEntity
    For i = 0 To ThisDrawing.ModelSpace.Count - 1
        Set ssobjs(i) = ThisDrawing.ModelSpace.Item(i)
    Next i
    ' Add the array of objects to the selection set
    ssetObj.AddItems ssobjs
    MsgBox "No. of items in sel. set = " & ssetObj.Count
    ssetObj.Clear
    MsgBox "No. of items in sel. set (after clearing) = " & ssetObj.Count
End Sub 

© Bricsys NV. All rights reserved.