Hi Alls,
I just create a program lisp to rotate an object,that object is an Arrow,if user move his cursor,the arrow should be follow cursor location,but my code still problem.
as a sample if cursor move to top drawing area,the arrow not to top position,maybe left or righ side,I want the arrow follow it the cursor moving,here that code.
; arbc is stand for Automatic Rotate By Cursor
; Design by : Adesu <Ade Suharna>
; Email : mteybid@yuasabattery.co.id
; Homepage : http://www.yuasa-battery.co.id
; Create : 05 December 2006
; Program no.: 0480/12/2006
; Edit by :
(defun massoc (key alist / x nlist) ; Jaysen Long
(foreach x alist
(if
(eq key (car x))
(setq nlist (cons (cdr x) nlist))
)
)
(reverse nlist)
)
(defun c:arbc (/ ang_arrow ang_cursor cen el gr head
loc lst p1 p2 p3 pt sse)
(setq loc '(0 0 0))
(setq p1 (polar loc 0 5))
(setq p2 (polar loc (* pi 0.75) 5))
(setq p3 (polar loc (* pi 1.25) 5))
(command "_pline" p1 p2 loc p3 "c" "")
(setq el (entlast))
(while
(setq gr (grread t 7))
(setq pt (cadr gr))
(setq ang_cursor (angle pt loc))
(setq sse (entget el))
(setq lst (massoc 10 sse))
(setq head (nth 0 lst))
(setq cen (nth 2 lst))
(setq ang_arrow (angle cen head))
(if
(not (eq ang_cursor ang_arrow))
(command "_rotate" el "" loc "r" 0 ang_cursor "")
) ; if
) ; while
(princ)
) ; defun