组合命令复制旋转可用,但改为移动不行
工作中经常碰到,要先移动一个对象然后再对其旋转,自己先写了个先复制再旋转可用,但是改为移动就不行,请各位大侠帮看看本帖最后由 自贡黄明儒 于 2022-5-11 18:12 编辑
用AL命令吧,一次到位。
;;11移动+旋转
(defun HH:MRotate (/ APP DOC P1 P2 P3 SS)
(setq app (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument app))
(vla-StartUndoMark doc)
(and (setq ss (ssget))
(setq p1 (getpoint "\n 移动基点:"))
(princ "\n 对齐点:")
(command "_.move" ss "" p1 pause)
)
(setq p3 (getvar "LASTPOINT"))
(setq p2 (getpoint "\n 旋转起点:"))
(and p1
p2
p3
(command "_.ROTATE" ss "" p3 "R" p3 p2 pause)
)
(vla-EndUndoMark doc)
(vlax-release-object doc)
(vlax-release-object app)
(princ)
)
本帖最后由 自贡黄明儒 于 2022-5-16 07:22 编辑
;;5 [功能] 获取在图元 en 之后产生的图元的选择集
(defun lt:ss-entnext (en / ss)
(if en
(progn
(setq ss (ssadd))
(while (setq en (entnext en))
(if (not (member (cdr (assoc 0 (entget en)))
'("ATTRIB"
"VERTEX"
"SEQEND"
)
)
)
(ssadd en ss)
)
)
(if (zerop (sslength ss))
(setq ss nil)
)
ss
)
(ssget "_x")
)
)
;;14拷贝+移动+旋转
(defun HH:CMRotate (/ APP DOC LASTENT P1 P2 P3 SS SS1)
(setq app (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument app))
(vla-StartUndoMark doc)
(setq Lastent (entlast))
(and (setq ss (ssget))
(setq p1 (getpoint "\n 移动基点:"))
(princ "\n 对齐点:")
(command "_.copy" ss "" p1 pause)
)
(setq ss1 (lt:ss-entnext Lastent))
(setq p3 (getvar "LASTPOINT"))
(setq p2 (getpoint "\n 旋转起点:"))
(and p1
p2
p3
(command "_.ROTATE" ss1 "" p3 "R" p3 p2 pause)
)
(vla-EndUndoMark doc)
(vlax-release-object doc)
(vlax-release-object app)
(princ)
)
(defun c:ydxz ()
"ydxz(移动旋转)"
(command "undo" "be")
(setq os (getvar "osmode"))
(setvar "osmode" 39)
(if (and (setq s1 (ssget))
(setq p1 (getpoint "\n请选择起点: "))
(setq p2 (getpoint p1 "\n请选取基点: "))
(setq p3 (getpoint p2 "\n请选取旋转点: "))
(setq p4 (getpoint p3 "\n请选取对其点: "))
)
(progn
(setvar "osmode" 0)
(setq rad (angle p3 p4))
(command "move" s1 "" p1 p2)
(command "rotate" s1 "" p2 (* (/ rad pi) 180))
)
)
(setvar "osmode" os)
(command "undo" "e")
(princ)
) 可以用了,谢谢自贡黄明儒侠,谢谢xyp1964侠 自贡黄明儒 发表于 2022-5-11 18:14
你这个少了这个lt:ss-entnext这个命令,不完整! 本帖最后由 陈伟 于 2022-5-25 15:35 编辑
xyp1964 发表于 2022-5-11 23:24
可以实现在移动过程中比如输入R就旋转90度的方法吗,或者粘贴输入R就旋转90度 wanhongron 发表于 2022-5-12 09:24
可以用了,谢谢自贡黄明儒侠,谢谢xyp1964侠
大佬把修改后的插件发出来
页:
[1]