- Private Sub SelectLots(ByVal Ssetname As String, ByVal strLayerName As String)
-
- Dim sSetObj As AcadSelectionSet, flag As Boolean
- If ThisDrawing.GetVariable("cmdactive") Then ThisDrawing.SendCommand "(command)"
-
- For Each sSetObj In ThisDrawing.SelectionSets
-
- If sSetObj.Name = Ssetname Then
- flag = True
- Exit For
- End If
-
- Next
-
- If flag Then sSetObj.Delete '创建集合,如集存在,则删除,新建
- Set sSetObj = ThisDrawing.SelectionSets.Add(Ssetname)
-
- Dim gpCode(0) As Integer
-
- Dim dataValue(0) As Variant
-
-
- gpCode(0) = 8
- dataValue(0) = strLayerName ' 图层名
-
- Dim groupCode As Variant, dataCode As Variant
-
- groupCode = gpCode
- dataCode = dataValue
-
- sSetObj.Select acSelectionSetAll, , , groupCode, dataCode
- End Sub
- Public Sub test()
- Dim objSset As AcadSelectionSet
- SelectLots "z1111", "0" '选0层的所有对象
- Set objSset = ThisDrawing.SelectionSets("z1111")
- If objSset.Count = 0 Then Exit Sub
- Dim objEnt As AcadEntity
- For Each objEnt In objSset
- Debug.Print objEnt.ObjectName
- Next objEnt
- End Sub
|