|
;对象居中:by zml84 2009-06-15 此基础上修改:by 忘霄
(defun C:EC (/ box en采用tmp ent i pt0 pt1 ss tmp)
(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)
) |
|