- (vl-load-com)
- (defun lwpts(lwen / lwdt)
- (setq lwdt (entget lwen))
- (vl-remove-if-not '(lambda(e1) (equal (car e1) 10)) lwdt)
- )
- (defun c:bh()
- (prompt "\nSelect 2 lwpolylines:")
- (setq ss (ssget '((0 . "lwpolyline"))))
- (or ss (setq ss (ssadd)))
- (setq len (sslength ss) m 0)
- (if (/= len 2)
- (princ "\n不是2根! ---程序退出......")
- (progn
- (setq en1 (ssname ss 0) en2 (ssname ss 1))
- (setq data1 (lwpts en1) data2 (lwpts en2))
- (setq pt1 (cdar data1) pt2 (cdr (last data1)))
- (setq pt3 (cdar data2) pt4 (cdr (last data2)))
- (setq dis1 (distance pt1 pt3) dis2 (distance pt1 pt4))
- (if (> dis1 dis2)(setq ptx pt3 pt3 pt4 pt4 ptx ptx nil))
- (entmake (list '(0 . "LINE") (cons 10 pt1) (cons 11 pt3)))
- (setq ss (ssadd (entlast) ss))
- (entmake (list '(0 . "LINE") (cons 10 pt2) (cons 11 pt4)))
- (setq ss (ssadd (entlast) ss))
- (setvar "cmdecho" 0)
- (setvar "peditaccept" 1)
- (command "pedit" "m" ss "" "j" "" "")
- (setvar "peditaccept" 0)
- (setvar "cmdecho" 1)
- )
- )
- (princ)
- )
|