Hi thanks for the reply,I add osmode 521 to give the option to snap on Endpoints, Node and Nearest at the End Point , but the snap is enabled but don't snap any ware in the drawing (for the end point). Why?
Code:
(setvar "OSMODE" 521) ; enpoint, node,nearest
and at the end to return
(setvar "OSMODE" 13) ;End ,center,node
Code:
(defun C:SLP ( / var_snap pt_start slope key pt_key pt_end)
(setq var_snap (getvar "SNAPANG"))
(initget 8)
(setq pt_start (getpoint "\nStart point: "))
(if (eq pt_start ()) (setq pt_start (getvar "LASTPOINT")))
(initget 1)
(setq slope (getreal "\nGive value of slope in en % ?: "))
(setvar "OSMODE" 521) ; enpoint, node,nearest
(princ "\nEnd Point: ")
(while (and (setq key (grread T 4 0)) (/= (car key) 3))
(cond
((eq (car key) 5)
(setq pt_key (cadr key))
(redraw)
(if (< (car pt_key) (car pt_start))
(setvar "SNAPANG" (- pi (atan (* slope 0.01))))
(setvar "SNAPANG" (atan (* slope 0.01)))
)
(grdraw pt_start (setq pt_end (polar pt_start (getvar "SNAPANG") (distance pt_start pt_key))) 7)
)
)
)
(redraw)
(setvar "SNAPANG" var_snap)
(setvar "LASTPOINT" pt_end)
(entmake
(list
(cons 0 "LINE")
(cons 100 "AcDbEntity")
(cons 67 (if (eq (getvar "CVPORT") 2) 0 1))
(cons 410 (if (eq (getvar "CVPORT") 2) "Model" (getvar "CTAB")))
(cons 8 (getvar "CLAYER"))
(cons 100 "AcDbLine")
(cons 10 (trans pt_start 1 0))
(cons 11 (trans pt_end 1 0))
(cons 210 (trans '(0 0 1) 1 0 T))
)
)
(prin1)
(setvar "OSMODE" 13) ;End ,center,node
)
Thanks