;;角平分线
(defun c:jpfx (/ a ang ang1 ang2 b cmd cla intp	l1 l1e l1s l2 l2e l2s
	       ort pt *error*
	      )
  (cond	((and
	   (setq l1 (car (entsel "\n直线Ａ:")))
	   (setq l2 (car (entsel "\n直线Ｂ:")))
	 )
	 (setq l1s (vlax-curve-getStartPoint l1))
	 (setq l1e (vlax-curve-getEndPoint l1))
	 (setq l2s (vlax-curve-getStartPoint l2))
	 (setq l2e (vlax-curve-getEndPoint l2))
	 (setq ang1 (angle l1s l1e))
	 (setq ang2 (angle l2s l2e))
	 (setq ang (* 0.5 (+ ang1 ang2)))
	 (or
	   (setq intp (inters l1s l1e l2s l2e nil))
	   (setq intp (mapcar '(lambda (a b) (* 0.5 (+ a b))) l1s l2s))
	 )
	 (defun *error* (msg) (command ".undo" "e" ".undo" 1))
	 (command ".undo" "be")
	 (setq cmd (getvar "CMDECHO"))
	 (setvar "CMDECHO" 0)
	 (setq ort (getvar "ORTHOMODE"))
	 (setvar "ORTHOMODE" 1)
	 (setq cla (getvar "clayer"))
	 (fsxm-maklayer "Center" 30 "Center2" nil)
	 (setvar "clayer" "Center")
	 (command
	   ".UCS"
	   "Z"
	   (* (- ang (angle '(0 0) (getvar "UCSXDIR"))) (/ 180 pi))
	 )
	 (cond
	   ((setq pt (getpoint "\nStartPoint:" (trans intp 0 1)))
	    (princ "\nEndPoint:")
	    (command ".line" "non" pt "\\")
	    (if	(> (getvar "cmdactive") 0)
	      (command "")
	    )
	   )
	 )
	 (command ".UCS" "P")
	 (setvar "CMDECHO" cmd)
	 (setvar "ORTHOMODE" ort)
	 (setvar "clayer" cla)
	 (command ".undo" "e")
	)
  )
  (princ)
)