请求完善程序:N多个圆、圆弧移动到指定点(同一个圆心点)
<p></p><p>想达到的目的:选取N多个圆、圆弧、椭圆和椭圆弧移动到指定点(最终必须是N多个圆同一个圆心点),</p><p>省去一个个操作的麻烦<br/></p><p>;;;圆、圆弧移动到指定点(同一个圆心点)<br/>(defun c:QQ ()(setvar "pickbox" 24)(setvar "cmdecho" 0) <br/>(setvar "CMDECHO" 0) <br/>(STRCAT "请选取要移动的圆、圆弧、椭圆和椭圆弧 :")<br/>(setq ss (ssget '((0 . "Arc,Circle,Ellipse"))))<br/> (= (sslength ss) 2)) <br/> (progn<br/> (setq en (ssname ss 0) ent (entget en))<br/> (if (= (cdr(assoc 0 ent)) '((0 . "Arc,Circle,Ellipse")))<br/> (setq en1 (ssname ss 1) ent1 (entget en1))<br/> (setq en1 en ent1 ent en (ssname ss 1) ent (entget en))<br/>)<br/> (setq pc (cdr(assoc 10 ent1))<br/> ptt (txtcen ent)) <br/>(setq pc (cdr (assoc 10 ent))))</p><p>(setq pt2 (getpoint "[选择目标点] : "))<br/>(command ".move" en "" ptt pc)<br/>))<br/>(setq SS nil) (setvar "cmdecho" 1)) </p> 大概改了一下;;; 圆、圆弧移动到指定点(同一个圆心点)
;;; qjchen modify
(defun c:qq ( / en i pc pt2 ss temp)
;(setvar "pickbox" 24)
(command "undo" "be")
(setvar "cmdecho" 0)
(setvar "CMDECHO" 0)
(prompt "请选取要移动的圆、圆弧、椭圆和椭圆弧 :")
(setq ss (ssget '((0 . "Arc,Circle,Ellipse"))))
(setq pt2 (getpoint "[选择目标点] : ")) ; (= (sslength ss) 2)
(setq i 0)
(setq temp (getvar "osmode"))
(setvar "osmode" 0)
(if ss
(progn
(repeat (sslength ss)
(setq en (ssname ss i))
(setq pc (cdr (assoc 10 (entget en))))
(command ".move" en "" pc pt2)
(setq i (1+ i))
)
)
)
(setvar "cmdecho" 1)
(setvar "osmode" temp)
(command "undo" "e")
)
<font color="#f70909">致谢qjchen</font> <p>在已知目标“点”的情况下,用ACAD的特性(properties)【快捷键为Ctrl+1】功能也不见得比程序慢:</p> 楼上好方法,直接在图中选点也可。 <p>好方法,谢2位 :)</p>
;;; another choice
;;; for Test only
(defun c:qq ( / acapp adoc pt2 vPt2)
(setq acapp (vlax-get-acad-object)
adoc (vla-get-activedocument acapp)
)
(vla-endundomark adoc)
(vla-startundomark adoc)
(prompt "请选取要移动的圆、圆弧、椭圆和椭圆弧 :")
(ssget '((0 . "Arc,Circle,Ellipse")))
(setq pt2 (getpoint "[选择目标点] : ")
vPt2 (vlax-3d-point pt2)
)
(vlax-for obj (vla-get-activeselectionset adoc)
(vla-put-center obj vPt2)
)
;; (mapcar 'vlax-release-object (list acapp adoc))
(vla-endundomark adoc)
(princ)
)
<p>谢谢楼上各位的好方法</p>
页:
[1]