快速镜像(试过才知道)。。。有源码的仅能直线镜像,编译的可以用于多段线等(核心源码为平分线),我自己也不知道用哪一个好,上2张图片
1、对直线有效,快速镜像
- (defun c:mirrmid (/ ss pt pt1)
- (setq oldosmode (getvar 'osmode))
- (setq oldorthomode (getvar 'orthomode))
- (setvar 'osmode 0)
- (setvar 'orthomode 0)
- (setvar 'cmdecho 0)
- (prompt "\n请选择要镜像的对象:")
- (if (setq s (ssget))
- (progn
- (setq n 0)
- (repeat (sslength s)
- (redraw (ssname s n) 3)
- (setq n (1+ n))
- )
- (prompt "\n请选择确定镜像的直线<小于2条>:")
- (if (setq ss (ssget '((0 . "LINE"))))
- (progn
- (setq n 0)
- (repeat (sslength s)
- (redraw (ssname s n) 4)
- (setq n (1+ n))
- )
- (cond
- ((= (sslength ss) 2)
- (setq p101 (cdr (assoc 10 (entget (ssname ss 0))))
- p102 (cdr (assoc 10 (entget (ssname ss 1))))
- p111 (cdr (assoc 11 (entget (ssname ss 0))))
- p112 (cdr (assoc 11 (entget (ssname ss 1))))
- p10 (polar p101
- (angle p101 p102)
- (/ (distance p101 p102) 2)
- )
- p11 (polar p111
- (angle p111 p112)
- (/ (distance p111 p112) 2)
- )
- )
- (if (equal p10 p11 1e-3)
- (setq p10 (polar p101
- (angle p101 p112)
- (/ (distance p101 p112) 2)
- )
- p11 (polar p111
- (angle p111 p102)
- (/ (distance p111 p102) 2)
- )
- )
- )
- )
- ((= (sslength ss) 1)
- (setq p10 (cdr (assoc 10 (entget (ssname ss 0))))
- p11 (cdr (assoc 11 (entget (ssname ss 0))))
- )
- )
- ((> (sslength ss) 2)
- (alert "\n最多选择2根线!")
- )
- )
- )
- )
- (cond ((<= (sslength ss) 2)
- (command "_.mirror" s "" p10 p11)
- (command pause)
- )
- )
- )
- )
- (setvar 'osmode oldosmode)
- (setvar 'orthomode oldorthomode)
- (princ)
- )
2、对直线多段线均有效
|