这个双向偏移代码,如何实现循环选择对像,谢谢
本帖最后由 depgfdepgf 于 2023-8-31 22:24 编辑(defun c:tt1 (/ ss)
;(while ;加入这个循环为何不起作用
[*] (if (not dist) (setq dist 240))
[*] (setq newdist dist)
[*] (princ (strcat "\n当前偏移距离:" (rtos dist) " <空格或者回车设置新距离>"))
[*] (while (= ss nil)
[*] (setq ss (ssget ":s"))
[*] (if (= ss nil)
[*] (progn
[*] (setq newdist (getdist (strcat "\n设置新距离:" "<" (rtos dist) ">")))
[*] (if (= nil newdist)(setq newdist dist)(setq dist newdist))
[*] )
[*] )
[*] )
[*] (if (and newdist ss)
[*] (vlax-for ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
[*] (mapcar '(lambda (x)(vla-offset ss x))(list newdist (- newdist)))
[*] )
[*] )
;);while
[*] (princ)
[*])
;;双向偏移 SNSJ 2004.3.8
(defun c:OffsetBoth (/ getds obj lynm ptlay)
(defun ptlay (x y)
(foreach obj (vlax-safearray->list (vlax-variant-value x))
(vla-put-layer obj y)
)
)
(setq getds
(getdist
(strcat "\n输入偏移距离<" (rtos (getvar "offsetdist")) ">:")
)
)
(or getds (setq getds (getvar "offsetdist")))
(setvar "offsetdist" getds)
(setq lynm (getvar "clayer"))
(while (ssget ":S" '((0 . "Arc,Circle,Ellipse,*Line")))
(vlax-for obj (vla-get-activeselectionset *doc*)
(ptlay (vla-offset obj getds) lynm)
(ptlay (vla-offset obj (* getds -1)) lynm)
(vlax-release-object obj)
)
)
(princ)
) ;(while ;加入这个循环为何不起作用
(while (= ss nil)
---------------
);while
;);while
好像是镶套循环的问题,我也遇到相同的问题,也想知道原因并解决问题,不知哪位大能解答一下,谢谢! 试试这样
(defun c:NM (/ ss)
(if (not dist) (setq dist 240))
(setq newdist dist)
(princ (strcat "\n当前偏移距离:" (rtos dist) " <空格或者回车设置新距离>"))
(while
(or
(setq ss (ssget ":s"))
(if (= ss nil)
(progn
(setq newdist (getdist (strcat "\n设置新距离:" "<" (rtos dist) ">")))
(if (= nil newdist)(setq newdist dist)(setq dist newdist))
)
)
)
(if (= ss nil)
(progn
(setq ss (ssget ":s"))
(if (and newdist ss)
(vlax-for ss (vla-get-activeselectionset (vla-get-activedocument (vlax-get-acad-object)))
(mapcar '(lambda (x)(vla-offset ss x))(list newdist (- newdist)))
)
)
)
)
)
(princ)
)
tigcat 发表于 2023-8-31 22:30
CAD提示错误哦 xj6019 发表于 2023-9-1 07:39
试试这样
(defun c:NM (/ ss)
(if (not dist) (setq dist 240))
能否设置成鼠标右键结束?现在得按ESC
页:
[1]