STORING objects of a particular LAYER in SELECTION SET

STORING objects of a particular LAYER in SELECTION SET

Anonymous
Not applicable
251 Views
2 Replies
Message 1 of 3

STORING objects of a particular LAYER in SELECTION SET

Anonymous
Not applicable
Hi, i am stuck with this point.
Kindly guide,
Thanks
Mniaz
0 Likes
252 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
here's a quick untested idea

emphasis on untested, but may give you the general
idea

 

Sub SelectLayerObjs(ByVal sLayName As
String)
    Dim LaySelSet As
AcadSelectionSet
  
    On Error Resume
Next
    Set LaySelSet =
ThisDrawing.SelectionSets.Item(sLayName)
      If
Err Then
       
Err.Clear
           
Set LaySelSet =
ThisDrawing.SelectionSets.Add(sLayName)
       
Else
       

       
LaySelSet.Clear
       
LaySelSet.Delete
      End If
'define type of
selection set (crossing, window, etc, in this case, all)
   
Dim mode As Integer
    mode = acSelectionSetAll
'this is a
selection set filter
    Dim gpCode(0) As
Integer
    Dim dataValue(0) As Variant
   
gpCode(0) = 8
    dataValue(0) =
sLayName
   
    Dim groupCode As Variant,
dataCode As Variant
    groupCode =
gpCode
    dataCode = dataValue
    'this
collects all objects on 'sLayName' layer into the seletion
set
    LaySelSet.Select mode, , , groupCode,
dataCode
    Dim NumOfLay As Integer
   
NumOfLay = LaySelSet.Count
    If NumOfLay = 1
Then
      MsgBox "There is only one lonely little
object on " & sLayName & " layer."
   
Else
      MsgBox "There are " & NumOfLay &
" objects on " & sLayName & " layer."
    End
If
  'clean up
   
LaySelSet.Clear
    LaySelSet.Delete
End
Sub


style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
Hi,
i am stuck with this point.
Kindly guide,
Thanks

Mniaz
0 Likes
Message 3 of 3

Anonymous
Not applicable
Thanks
It worked very well.
Mniaz
0 Likes