- ;;说明:框选直线,在框内端点连接成样条曲线
- (defun C:ES(/ 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)))
- (if (and (setq pt1 (getpoint "\n指定第一个角点:"))(setq pt2 (getcorner pt1 "指定第二个角点,确保连接的点在框内:")) (setq ss (ssget "C" pt1 pt2 '((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 (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)
- )
|