BudPerry Posted July 9, 2012 Posted July 9, 2012 after searching around I finally found the following code to find the angle between two points: (setq p1 (getpoint "\nSelect First Point: ")) (setq p2 (getpoint "\nSelect Second Point: ")) (setq ang1 (angle p1 p2)) However, when I test this by either priting ang1, or by adding the following line of code for text, (command "_text" "_J" "_tc" "_non" p1 6.0 ang1 "testing angle") the angle seems to only vary from .5 to about 2.0 and never matches what you'd expect from the p1 and p2 angle (perhaps 48 or 89 degrees). Could it be that the angle it's grabbing is in some other form and I need to convert it? Quote
MSasu Posted July 9, 2012 Posted July 9, 2012 Please pay attention that ANGLE function return the angle in radians, while that command is expecting it in degrees. Quote
MSasu Posted July 9, 2012 Posted July 9, 2012 Glad to hear that your issue is solved. Since you will encounter such case many times from now, I strongly suggest you to define a pair of dedicated functions for Radians-to-Degrees, respectively Degrees-to-Radians conversion. Quote
BIGAL Posted July 10, 2012 Posted July 10, 2012 (edited) Heres the two rtd dtr you want also you need to remember that whilst the answer will always be radians it also ignores the UNITS direction setting so 0 is always horizontal to right so sometimes need a bit extra to take into account the north brg as up page at 0. ;The dtr function converts degrees to radians ;The rtd function converts radians to degrees (defun dtr (a) (* pi (/ a 180.0)) ) ; (defun rtd (a) (/ (* a 180.0) pi) ) Edited July 10, 2012 by BIGAL Quote
Tharwat Posted July 10, 2012 Posted July 10, 2012 Building on Mircea and Bigal 's suggestions and answers . (command "_.text" "_J" "_tc" "_non" p1 6.0 (/ (* ang1 180.0) pi) "testing angle") Quote
pBe Posted July 10, 2012 Posted July 10, 2012 Factors you need to consider when using command approach Current UCS (setq p1 (getpoint "\nSelect First Point: ")) (setq p2 (getpoint [b][color=blue]p1[/color][/b] "\nSelect Second Point: ")) (setq ang1 (angle [b][color=blue](trans p1 1 0)[/color][/b] [color=blue][b](trans p2 1 0)[/b][/color])) Current textsyle If Textstyle height is defined on the current TEXTSYLE, instead of "testing angle" you will get the angle value for string and 6.0 as the angle HTH Quote
MSasu Posted July 10, 2012 Posted July 10, 2012 If Textstyle height is defined on the current TEXTSYLE, instead of "testing angle" you will get the angle value for string and 6.0 as the angle That's a good point, pBe; a possible workaround: (command "_TEXT" textPoint) (if (= (cdr (assoc 40 (entget (tblobjname "STYLE" (getvar "TEXTSTYLE"))))) 0.0) (command textHeight) ) (command textAngle textLabel) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.