本帖最后由 ZZXXQQ 于 2014-2-27 22:00 编辑
- ;;;统计相同矩形边长的数量.
- ;;;编写日期2013-07-05
- ;;;编写: CADMAN
- ;;子函数 (求矩形边长)
- (defun qbc (pts / b h)
- (setq b (distance (car pts) (cadddr pts)))
- (setq h (distance (car pts) (cadr pts)))
- (cons (max b h) (min b h))
- );结束qbc
- (defun c:tg ( / bclst pts ss el bc_new i p2 p3 m x1 x2)
- (princ "\n请框选矩形:")
- (setq ss (ssget '((0 . "LWPOLYLINE") (90 . 4))))
- (setq i 0 bclst nil pts nil)
- (repeat (sslength ss)
- (setq el (entget (ssname ss i)))
- (setq pts nil)
- (foreach pt el (if (= (car pt) 10) (setq pts (cons (cdr pt) pts))))
- (setq bclst (cons (qbc pts) bclst))
- (setq i (1+ i))
- );repeat
- (setq bc_new nil)
- (while bclst
- (setq m (car bclst) x1 (length bclst))
- (setq bclst (vl-remove m bclst))
- (setq x2 (length bclst))
- (setq n (- x1 x2))
- (setq bc_new (cons (list m n) bc_new))
- )
- (setq p2 (getpoint "\起始位置"))
- (setq p3 (polar p2 0 3000))
- (command "_.TEXT" "c" (polar p2 (* pi 0.5) 800) "500" "0" "矩形边长");指定书写标题的位置
- (command "_.TEXT" "c" (polar p3 (* pi 0.5) 800) "500" "0" "数量")
- (foreach bg bc_new ;设定重复次数为新表的长度
- (command "_.TEXT" "c" p2 "400" "0" (strcat (rtos (car (car bg)) 2)"x" (rtos (cdr (car bg))2)))
- (command "_.TEXT" "c" p3 "400" "0" (cadr bg))
- (setq p2 (polar p2 (* pi 1.5) 800))
- (setq p3 (polar p2 0 3000))
- )
- (princ)
- )
|