本帖最后由 434939575 于 2015-4-24 09:44 编辑
- (defun c:tt ( / 1:xy 1:z 1> 2> 2pt 3> 9:xy 9:z ang las leng lst p1 p9 pt:bo ptma ptmi s wid z)
- (vl-load-com)
- (setq s (car (entsel)))
- (vla-getboundingbox
- (vlax-ename->vla-object s)
- 'ptmi
- 'ptma
- )
- (setq 2pt (mapcar 'vlax-safearray->list (list ptmi ptma)))
- (setq p1 (car 2pt))
- (setq p9 (cadr 2pt))
- (setq 1:z (caddr p1))
- (setq 9:z (caddr p9))
- (setq z (abs (- 9:z 1:z)))
- (setq 1:xy (reverse (cdr (reverse p1))))
- (setq 9:xy (reverse (cdr (reverse p9))))
- (setq ang (angle 1:xy
- 9:xy
- )
- )
- (setq pt:bo (polar 1:xy ang (/ (distance 1:xy 9:xy) 2)))
- (setq pt:bo (append pt:bo (list 9:z)))
- (command "BOUNDARY" pt:bo "")
- (setq las (entlast))
- (setq lst (Hx-pl-list las))
- (entdel las)
- (setq 1> (car lst))
- (setq 2> (cadr lst))
- (setq 3> (caddr lst))
- (setq leng (distance 1> 2>))
- (setq wid (distance 2> 3>))
- (print (strcat "长"
- (rtos leng 2 2)
- "宽"
- (rtos wid 2 2)
- "高"
- (rtos z 2 2)
- )
- )
- (princ)
- ) ;end
- (defun Hx-pl-list (SS0 / e elist ptlist) ;端点列表
- (setq elist (entget SS0))
- (foreach n elist
- (if (= 10 (car n))
- (setq ptlist (cons (cdr n) ptlist))
- )
- )
- (reverse ptlist)
- )
|