http://bbs.mjtd.com/forum.php?mod=viewthread&tid=181585&highlight=%BE%D3%D6%D0
;对象居中:by zml84 2009-06-15 此基础上修改:by 忘霄
(defun C:EC(/ box en_tmp ent i pt0 pt1 ss tmp);;;entity center ==> EC
(setvar "CMDECHO" 0)
(vl-load-com)
(princ "\n选择需要居中的对象:")
(if (setq ss (ssget))
(progn
(defun box(e / ll ur)
(vla-getboundingbox (vlax-ename->vla-object e) 'll 'ur)
(mapcar 'vlax-safearray->list (list ll ur))
)
(setq i -1)
(command "undo" "be")
(while (setq ent (ssname ss (setq i (1+ i))))
(setq tmp (box ent))
(setq tmp (mapcar '+ (car tmp) (cadr tmp)))
(setq pt0 (mapcar '* tmp '(0.5 0.5 0.5)))
(entdel ent)
(setq en_tmp (bpoly pt0))
(entdel ent)
(setq tmp (box en_tmp))
(setq tmp (mapcar '+ (car tmp) (cadr tmp)))
(setq pt1 (mapcar '* tmp '(0.5 0.5 0.5)))
(command "move" ent "" "non" pt0 "non" pt1)
(entdel en_tmp)
)
(command "undo" "e")
)
(princ "\n没有选择对象!")
)
(princ)
)