中心镜像
原贴忘记是那个大佬的了,我想讨论的是希望有人能合并两个命令为一个命令来用命令后框选对象直接空格X轴中心镜像,命令后框选对象加 D 则Y轴中心镜像
太多程序和命令,连本人都记不住,所以想着让同类命令能合并一起这样少记通用。
lee50310大佬就合并过隐藏显示命令,这次的想法和这个一样
http://bbs.mjtd.com/forum.php?mod=viewthread&tid=184590&page=1&extra=#pid903644
快捷键ggyY轴中心镜像
(defun c:ggy(/ sc a b);;;;各自中心上下镜像
(while (ssget)
(vlax-for obj
(vla-get-ActiveSelectionSet
(vla-get-ActiveDocument (vlax-get-acad-object)))
(if (not (VL-CATCH-ALL-ERROR-P
(VL-CATCH-ALL-APPLY
'vla-GetBoundingBox
(list obj 'a 'b))))
(progn
(setq bp(mapcar '*'(0.5 0.5 0.5)(apply 'mapcar (cons '+ (mapcar 'vlax-safearray->list(list a b))))))
(setq ep(list (1+ (car bp))(cadr bp) (caddr bp)))
(vla-transformby obj (vlax-tmatrix (mirror2dmat bp ep)))
)
)
)
)
(princ)
)
快捷键ggxX轴中心镜像
(defun c:ggx(/ sc a b);;;;各自中心左右镜像
(while (ssget)
(vlax-for obj
(vla-get-ActiveSelectionSet
(vla-get-ActiveDocument (vlax-get-acad-object)))
(if (not (VL-CATCH-ALL-ERROR-P
(VL-CATCH-ALL-APPLY
'vla-GetBoundingBox
(list obj 'a 'b))))
(progn
(setq bp(mapcar '*'(0.5 0.5 0.5)(apply 'mapcar (cons '+ (mapcar 'vlax-safearray->list(list a b))))))
(setq ep(list (car bp) (1+ (cadr bp)) (caddr bp)))
(vla-transformby obj (vlax-tmatrix (mirror2dmat bp ep)))
)
)
)
)
(princ)
)
(defun mirror2dmat(sp ep / i a0 a1 a2 a3 t1 sp a b)
(setq i '((-1 0 0) (0 -1 0)(0 0 1)))
(setq a0(mapcar '- ep sp))
(setq a1(distance a0 (list 0 0 0)))
(setq a2(/ 1 a1))
(setq a3(mapcar '(lambda(y)(* y a2)) a0)
t1(mapcar '(lambda(x)(mapcar '(lambda(y)(* x y)) a3)) a3)
t1(mapcar '(lambda(x)(mapcar '(lambda(y)(* 2 y)) x))t1)
t1(mapcar '(lambda(x y)(mapcar '+ x y)) t1 i))
(setq sp(mapcar '- sp (mapcar '(lambda(x)(apply '+ (mapcar '* x sp))) t1)))
(setq a (car t1)
b (cadr t1))
(list
(list (car a)(cadr a)(caddr a) (car sp))
(list (car b)(cadr b)(caddr b) (cadr sp))
'(0 0 1 0)
'(0 0 0 1))
)
(defun c:NM (/ a b bbmmi bp ep mirror2dmat sc);;;;
(defun mirror2dmat(sp ep / i a0 a1 a2 a3 t1 sp a b)
(setq i '((-1 0 0) (0 -1 0)(0 0 1)))
(setq a0(mapcar '- ep sp))
(setq a1(distance a0 (list 0 0 0)))
(setq a2(/ 1 a1))
(setq a3(mapcar '(lambda(y)(* y a2)) a0)
t1(mapcar '(lambda(x)(mapcar '(lambda(y)(* x y)) a3)) a3)
t1(mapcar '(lambda(x)(mapcar '(lambda(y)(* 2 y)) x))t1)
t1(mapcar '(lambda(x y)(mapcar '+ x y)) t1 i))
(setq sp(mapcar '- sp (mapcar '(lambda(x)(apply '+ (mapcar '* x sp))) t1)))
(setq a (car t1)
b (cadr t1))
(list
(list (car a)(cadr a)(caddr a) (car sp))
(list (car b)(cadr b)(caddr b) (cadr sp))
'(0 0 1 0)
'(0 0 0 1))
)
(setq bbMMI nil)
(while (ssget)
(vlax-forobj
(vla-get-ActiveSelectionSet
(vla-get-ActiveDocument (vlax-get-acad-object)))
(if (not (VL-CATCH-ALL-ERROR-P
(VL-CATCH-ALL-APPLY
'vla-GetBoundingBox
(list obj 'a 'b))))
(progn
(OR
bbMMI
(PROGN
(initget "X D")
(if (not bbMMI) (setq bbMMI "X"))
(setq bbMMI
(cond
( (getkword (strcat "【瞎玩版】 \n请选择镜像轴<" bbMMI "> : " )))
( bbMMI )
)
)
)
)
(cond
((= bbMMI "X")
(setq bp(mapcar '*'(0.5 0.5 0.5)(apply 'mapcar (cons '+ (mapcar 'vlax-safearray->list(list a b))))))
(setq ep(list (car bp) (1+ (cadr bp)) (caddr bp)))
(vla-transformby obj (vlax-tmatrix (mirror2dmat bp ep)))
)
((= bbMMI "D")
(setq bp(mapcar '*'(0.5 0.5 0.5)(apply 'mapcar (cons '+ (mapcar 'vlax-safearray->list(list a b))))))
(setq ep(list (1+ (car bp))(cadr bp) (caddr bp)))
(vla-transformby obj (vlax-tmatrix (mirror2dmat bp ep)))
)
)
)
)
)
)
(princ)
)
;;;通过点四向镜像
(defun c:mii (/ obj pt obj1 oldos)
(princ "\n请选择四向镜像的对象:")
(setq obj (ssget))
(princ "\n请选择镜像点:")
(setq pt (getpoint))
(if (and obj pt)
(progn
(command ".undo" "BE")
(setq oldos (getvar "osmode"))
(setvar "osmode" 0)
(command "_.mirror" obj "" pt (list (car pt)(+ (cadr pt) 10)) "N")
(setq obj1 (entlast))
(command "_.mirror" obj "" pt (list (+ (car pt) 10) (cadr pt)) "N")
(command "_.mirror" obj1 "" pt (list (+ (car pt) 10) (cadr pt)) "N")
(setvar "osmode" oldos)
(command ".undo" "E")
)
(princ "\n没有选择对象或镜像点!")
)
(princ)
) 你是起的真早 可以减少记忆量 支持支持! (if (= (getstring":") "d") (c:ggy) (c:ggx)) 多谢楼主分享{:1_1:} start4444 发表于 2023-7-6 11:07
(if (= (getstring":") "d") (c:ggy) (c:ggx))
我也这么干,哈哈 xj6019 发表于 2023-7-6 07:59
(defun c:NM (/ a b bbmmi bp ep mirror2dmat sc);;;;
(defun mirror2dmat(sp ep / i a0 a1 a2 a3 t1 ...
感谢大佬,正是我想要的效果
页:
[1]
2