Message 1 of 3
VBA GetObject doesn't get all lines?
Not applicable
07-25-2019
03:25 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have code below that contains the issue, and an image that shows the difference. The red/orange objects I have drawn, the grey ones have been imported. Why does the code only apply to the drawn lines, and how can I make it apply to ALL lines? Red = Drawn, grey = imported
Set objApp = GetObject(, "AutoCAD.Application")
Set objDoc = objApp.ActiveDocument
Dim ang As Double
For Each Obj In objDoc.ModelSpace
On Error Resume Next
ang = Obj.Angle
ang = Round(ang * 180 / pi, 0)
If Err.Number <> 0 Then
Err.Clear
GoTo jump_nextObj
End If
Obj.Select
Debug.Print ang * 180 / pi
'If Obj.Length > 480 And ang * 180 / pi = 0 Then
If Obj.Length > 10 Then
If ang = 0 Or ang = 90 Or ang = 270 Then
Obj.Color = 1
End If
End If