I cant get this to work. What im trying to do is fix a drawing a consultant sent me. his text is not all at 0 or 90 degrees. I want to check each piece of dtext and mtext for rotation, and fix the non-standard ones. here is my codeOption Explicit
Public Sub FIX_ROTATION()
Dim objSelected As Object
Dim objTxt As AcadText
Dim objMTxt As AcadMText
Dim objSelSet As AcadSelectionSet
On Error GoTo ErrControl
Dim N As Integer
Dim pi
pi = 4 * Atn(1)
If ThisDrawing.SelectionSets.Count > 0 Then
For N = 0 To ThisDrawing.SelectionSets.Count - 1
If ThisDrawing.SelectionSets.Item(N).Name = "FIXTEXT" Then
ThisDrawing.SelectionSets("FIXTEXT").Delete
End If
Next N
End If
Set objSelSet = ThisDrawing.SelectionSets.Add("FIXTEXT")
objSelSet.SelectOnScreen
'objSelSet.Select acSelectionSetAll
For Each objSelected In objSelSet
If TypeOf objSelected Is AcadText Then
Set objTxt = objSelected
Select Case objTxt.Rotation
Case 0:
objTxt.Rotation = 0
Case 90:
objTxt.Rotation = (pi / 2)
Case objTxt.Rotation < (pi / 2) <---- here is the problem. Im trying to find text w/ > 0 but < 75 degrees
objTxt.Rotation = 0
Case Else
objTxt.Rotation = (pi / 2)
End Select
End If
Next
' For Each objSelected In objSelSet
' If TypeOf objSelected Is AcadText Then
' Set objTxt = objSelected
' If objTxt.Rotation > 0 And objTxt.Rotation < 75 Then
' objTxt.Rotation = 0
' Else: objTxt.Rotation = (pi / 2)
' End If
'
' End If
' Next
' For Each objSelected In objSelSet
' If TypeOf objSelected Is AcadMText Then
' Set objMTxt = objSelected
' If objMTxt.Rotation > 0 And objMTxt.Rotation < 75 Then
' objMTxt.Rotation = 0
' Else: objMTxt.Rotation = 90
' End If
'
' End If
' Next
ThisDrawing.SelectionSets.Item("FIXTEXT").Delete
ThisDrawing.Application.Update
Exit_Here:
Exit Sub
ErrControl:
MsgBox Err.Description
ThisDrawing.SelectionSets.Item("FIXTEXT").Delete
End Sub
I started using IF statements, but didn't want to nest 4 levels deep