Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I wanted to rotate MText ( which is at the middle of MLine drawn ) according to the alignment of MLine drawn on Modelspace.
Cases:
i)If Mline is Horizontal the MText should be horizontal.
ii)If Mline is Vertical the MText should be vertical.
iii)If Mline is Diagonal the MText should be diagonal ie according to alignment of MLine.
I have used Tan(θ)=Perpendicular/Base to get the angle at which the MLine is drawn on Modelspace but the alignment of MText does not match the alignment of MLine.
P.S: I have solved for Case I and Case II using If-Else but for Case III: Diagonal, I could not figure out a way to solve it.
Start = acadDoc.Utility.GetPoint(, "Start point :")
Finish = acadDoc.Utility.GetPoint(Start, "End point :")
point(0) = Start(0)
point(1) = Start(1)
point(2) = Start(2)
point(3) = Finish(0)
point(4) = Finish(1)
point(5) = Finish(2)
Set MLine = acadDoc.ModelSpace.AddMLine(point)
Inspoint(0) = (point(0) + point(3)) / 2
Inspoint(1) = (point(1) + point(4)) / 2
TextString = "I am at Mid-Point"
Set MTextObj = acadDoc.ModelSpace.AddMText(Inspoint, 0, TextString)
MTextObj.Rotation = Atn((point(4) - point(1)) / (point(0) - point(3)))-90 * 0.0174532925
Solved! Go to Solution.