;;说明:框选直线,在框内端点连接成样条曲线
(defun C:ES(/ delsame dxf10 dxf11 edata ent isptinrectang n pt1 pt2 ptlst ss)
;;;判断p点是否在P1,P2构成的矩形框内
;;;(IsPtInRectang (getpoint) (getpoint) (getpoint))
(defun IsPtInRectang(p1 p2 p) (vl-every '>= (mapcar '* (mapcar '- p p1) (mapcar '- p2 p)) '(0 0)))
(defun delsame(l1 / l2);;表中去除重复元素(重复过的取第一次出现)
(while (setq l2 (cons (car l1) l2) l1 (vl-remove (car l1) (cdr l1))))
(reverse l2)
)
(if (and (setq pt1 (getpoint "\n指定第一个角点:"))(setq pt2 (getcorner pt1 "指定第二个角点,确保连接的点在框内:")) (princ "\n请选择链接的直线:") (setq ss (ssget '((0 . "LINE")))))
(progn
(setq ptlst nil n -1)
(while (setq ent (ssname ss (setq n (1+ n))))
(setq edata (entget ent) dxf10 (cdr (assoc 10 edata)) dxf11 (cdr (assoc 11 edata)))
(if (IsPtInRectang pt1 pt2 dxf10) (setq ptlst (cons dxf10 ptlst)))
(if (IsPtInRectang pt1 pt2 dxf11) (setq ptlst (cons dxf11 ptlst)))
)
(setq ptlst (delsame ptlst) ptlst (vl-sort ptlst (function (lambda(p1 p2) (< (car p1) (car p2))))))
(entmake (append (list '(0 . "SPLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbSpline")
'(71 . 3)
)
(mapcar '(lambda (pt) (cons 11 pt)) ptlst)
)
)
)
)
(prin1)
)