- Sub SelectLine()
- Dim sS As AcadSelectionSet
- Dim objLine As AcadLine
- Dim LineDelta As Variant
- Dim removeObjects() As AcadEntity
- Dim fType(0 To 0) As Integer
- Dim fData(0 To 0) As Variant
- Dim AutoSelect As Boolean
- 'AutoSelect = True
- On Error Resume Next
- ThisDrawing.SelectionSets("SelectText").Delete
- Set sS = ThisDrawing.SelectionSets.Add("SelectText")
- On Error GoTo 0
- On Error GoTo ErrHandle
- '创建过滤机制
- fType(0) = 0: fData(0) = "LINE" '直线
- '选择符合条件的所有图元-单行文字和多行文字
- If AutoSelect Then
- '自动选择方式
- sS.Select acSelectionSetAll, , , fType, fData
- Else
- '提示用户选择
- sS.SelectOnScreen fType, fData
- End If
- If sS.Count = 0 Then Exit Sub
- i = 0
- For Each objLine In sS
- LineDelta = objLine.Delta
- If LineDelta(0) <> 0 Then
- ReDim Preserve removeObjects(i)
- Set removeObjects(i) = objLine
- i = i + 1
- End If
- Next
-
- sS.RemoveItems removeObjects
-
- For Each objLine In sS
- a = objLine.StartPoint
- b = a(0)
- c = c & b & vbNewLine
- Next
-
- MsgBox c
- '删除数组
- Erase fType: Erase fData: Erase removeObjects: Erase LineDelta
- '删除选择集
- sS.Clear: sS.Delete
-
- Set sS = Nothing
- Set objLine = Nothing
- Exit Sub
- ErrHandle:
- MsgBox Err.Description, vbCritical, "产生了以下错误:"
- Err.Clear
- End Sub
|