- ;画出能框起选择集内所有图元的最小矩形框
- (defun get_all_rectang (ss / pt_list sn n en pt1 pt2)
- (setq pt_list '())
- (setq sn (sslength ss))
- (setq n -1)
- (repeat sn
- (setq en (ssname ss (setq n (1+ n))))
- (vla-getboundingbox (vlax-ename->vla-object en) 'pt1 'pt2)
- (setq pt_list (cons (vlax-safearray->list pt1) pt_list))
- (setq pt_list (cons (vlax-safearray->list pt2) pt_list))
- )
- (setq pt1 (apply 'mapcar (cons 'min pt_list)))
- (setq pt2 (apply 'mapcar (cons 'max pt_list)))
- (list pt1 pt2)
- )
- (defun c:tt(/ ss p0 lst p1 p2 dpt mpt)
- (if (and (setq ss(ssget))
- (setq p0(getpoint"\n选择中点:"))
- )
- (progn
- (setq bak_cmd(getvar 'cmdecho))
- (setvar 'cmdecho 0)
- (setq lst(get_all_rectang ss)
- p1 (car lst)
- p2 (cadr lst)
- mpt(mapcar '(lambda(x y)(* 0.5 (+ x y))) p1 p2)
- dpt(list(car p0)(cadr mpt))
- )
- (command "_move" ss "" "non" mpt "non" dpt)
- (and bak_cmd(setvar 'cmdecho bak_cmd))
- )
- )
- (princ)
- )
|