对于顶来来的帖子,觉得院长的演示很有意思,自己写个。- ;;测试程序
- (defun c:tt(/ p1 p2 ltlst)
- (if (setq p1 (getpoint "\n指定第一点: "))
- (if (setq p3(getcorner p1 "\n指定对角"))
- (progn
- (setq ptlst(sk_spts p1 p3))
- (entmake (list '(0 . "TEXT")(cons 72 1)(cons 73 2) (cons 1 "1")(cons 11 (car ptlst)) (cons 10 (car ptlst)) (cons 40 (/ (distance p1 p3) 10))))
- (entmake (list '(0 . "TEXT")(cons 72 1)(cons 73 2) (cons 1 "2")(cons 11 (cadr ptlst)) (cons 10 (cadr ptlst)) (cons 40 (/ (distance p1 p3) 10))))
- (entmake (list '(0 . "TEXT")(cons 72 1)(cons 73 2) (cons 1 "3")(cons 11 (caddr ptlst)) (cons 10 (caddr ptlst)) (cons 40 (/ (distance p1 p3) 10))))
- (entmake (list '(0 . "TEXT")(cons 72 1)(cons 73 2) (cons 1 "4")(cons 11 (caddr(cdr ptlst))) (cons 10 (caddr(cdr ptlst))) (cons 40 (/ (distance p1 p3) 10))
- ))
- (entmake (append(list'(0 . "LWPOLYLINE") '(100 . "AcDbEntity")'(100 . "AcDbPolyline")
- (cons 90 (length ptlst))
- (cons 70 1))
- (mapcar '(lambda (pt)(cons 10 pt)) ptlst )))
- )
- )
- )
- (princ)
- )
- ;;对角点计算函数,返回4个角点点表,起点为第一点,顺时针方向.
- (defun sk_spts(p1 p3 / p2 p4 ptlst)
- (if(or (and (< (car p1)(car p3))(>(cadr p1)(cadr p3)))
- (and (> (car p1)(car p3))(<(cadr p1)(cadr p3)))
- )
- (progn
- (setq p2(list (car p3) (cadr p1) 0)
- p4(list (car p1) (cadr p3) 0)
- )
- )
- (progn
- (setq p2(list (car p1) (cadr p3) 0)
- p4(list (car p3) (cadr p1) 0)
- )
- )
- )
- (setq ptlst(list p1 p2 p3 p4))
- ptlst
- )
-
-
|