- (defun c:Mr (/ gxl-MidPoint gxl-GetssBox )
- (defun gxl-MidPoint (p1 p2)
- (if (> 2 (length p1))
- (list (* 0.5 (+ (car p1) (car p2))) (* 0.5 (+ (cadr p1) (cadr p2))) (* 0.5 (+ (caddr p1) (caddr p2))))
- (list (* 0.5 (+ (car p1) (car p2))) (* 0.5 (+ (cadr p1) (cadr p2))))
- )
- )
- (defun gxl-Sel-SS->List (ss / cs_i out)
- (if (= (type ss) 'PICKSET)
- (progn
- (setq cs_i 0.0
- out '()
- )
- (repeat (sslength ss)
- (setq out (cons (ssname ss cs_i) out))
- (setq cs_i (1+ cs_i))
- )
- (setq out (reverse out))
- )
- )
- )
- (defun gxl-getbox (e1 / obj minpoint maxpoint)
- (if (= 'ENAME (type e1))
- (setq obj (vlax-ename->vla-object e1)) ;转换图元名
- (setq obj e1)
- )
- (vla-GetBoundingBox obj 'minpoint 'maxpoint)
- ;取得包容图元的最大点和最小点
- (setq minpoint (vlax-safearray->list minpoint)) ;把变体数据转化为表
- (setq maxpoint (vlax-safearray->list maxpoint)) ;把变体数据转化为表
- ;;(command "box" minpoint maxpoint 2)
- (setq obj (list minpoint maxpoint))
- )
- (setq oldosmode (getvar "osmode"))
- (setvar "osmode" 0)
- (princ "\n选择要镜像的物体:")
- (setq ss (ssget))
- (if ss
- (progn
- (setq pt1(getpoint "\n指定镜像线的第一点:")
- pt2 (getpoint pt1 "\n指定镜像线的第二点:")
- )
- (command "line" pt1 pt2 "")
- (setq line (entlast))
- (initget 7 "Yes No ")
- (setq kd (getkword "\n是否删除源对象?[是<Yes>/否<No>]否<No>"))
- (if (= kd "") (setq kd "No"))
- (setq nn (sslength ss)
- n 0)
- (repeat nn
- (setq pl (GXL-GETBOX (setq en (ssname ss n))))
- (setq pt (GXL-MIDPOINT (car pl) (cadr pl)))
- (setq mpt (vlax-curve-getclosestpointto line pt t))
- (setq ang (angle pt mpt))
- (command "copy" en "" pt (polar pt ang (* 2 (distance pt mpt))))
-
- (if (= kd "Yes") (command "erase" en ""))
- (setq n (1+ n))
- )
- )
-
- )
- (entdel line)
- (setvar "osmode" oldosmode)
- )
|