Hi Friends, in this article I will explain about how to get the anglebetween two points or two lines in the AutoLISP and the AutoCAD.
First of all open the
Visual LISP Editor; I already explained in the previous article how to open Visual LISP Editor in
AutoCAD.
Open the AutoCAD, Write the following lines.
1. (setq P1 (getpoint "Enter first point: "))
2.
(setq P2 (getpoint
"Enter second point: "))
3.
(setq A1 (angle P1
P2))
For more information follow the below commands in the AutoCAD command
prompt.
Command: (setq P1 (getpoint
"Enter first point: "))
Enter first point: (-3531.89
-1005.1 0.0)
Command: 'VLIDE
Command:
Command: (setq P2 (getpoint
"Enter second point: "))
Enter second point: (-3472.73
-872.155 0.0)
Command: 'VLIDE
Command:
Command: (setq A1 (angle P1
P2))
1.1521
|
Write the below code or
Simply Copy and Paste the below code.
(defun c:ang()
(setq P1 (getpoint "Enter first point:
"))
(setq P2 (getpoint "Enter second
point: "))
(setq A1 (angle P1 P2))
(setq d1 (dtr A1))
(alert (strcat (rtos d1)))
)
;;;;;;;;;
(defun dtr (a)
(/ (* a 180.0) pi)
)
|
In the above program getpoint is
allows the user to select a single point and
also to create a point in reference to the total input from the user.
In the above program (setq A1 (angle P1 P2)) returns the angle in radians, then i convert the radians to degrees using the DTR funtion.
Save the file as angle.LSP
Then write the below line in the AutoCAD Command prompt.
Command: (load “angle”)
Command:ang
|
Then the output will like in
the below figure.
No comments:
Post a Comment