;;*******************************************************************
;; 僙儞僞乕儔僀儞偺嶌惉(俀捈慄巜帵)
;; programed by Y.EBATA
;;*******************************************************************
(defun C:cenline ()
(setq somde (getvar "osmode"))
(setq secho (getvar "cmdecho"))
(setvar "osmode" 0)
(setvar "cmdecho" 0) ;---------------------------婎弨慄偺慖戰
(setq ee (entsel "\n侾杮栚偺捈慄傪巜帵:"))
(setq ename1 (car ee))
(redraw ename1 3)
(setq alist (entget ename1)
sp1 (cdr (assoc 10 alist))
ep1 (cdr (assoc 11 alist))
)
(setq ee (entsel "\n俀杮栚偺捈慄傪巜帵:"))
(setq ename2 (car ee))
(setq alist (entget ename2)
sp2 (cdr (assoc 10 alist))
ep2 (cdr (assoc 11 alist))
) ;---------------------------巒廔揰嵗昗嶼弌
(setq flg (inters sp1 sp2 ep1 ep2))
(if (/= flg nil)
(setq dum sp2
sp2 ep2
ep2 dum
)
)
(setq p1x (car sp1)
p1y (cadr sp1)
p2x (car sp2)
p2y (cadr sp2)
mix (min p1x p2x)
mxx (max p1x p2x)
miy (min p1y p2y)
mxy (max p1y p2y)
pmx (+ mix (/ (- mxx mix) 2.0))
pmy (+ miy (/ (- mxy miy) 2.0))
smp (list pmx pmy)
)
(setq p1x (car ep1)
p1y (cadr ep1)
p2x (car ep2)
p2y (cadr ep2)
mix (min p1x p2x)
mxx (max p1x p2x)
miy (min p1y p2y)
mxy (max p1y p2y)
pmx (+ mix (/ (- mxx mix) 2.0))
pmy (+ miy (/ (- mxy miy) 2.0))
emp (list pmx pmy)
) ;---------------------------張棟
(command "line" smp emp "")
(redraw)
(setvar "osmode" somde)
(setvar "cmdecho" secho)
)