一个上下左右平移文字的程序
我用过外源码改成了 上下 和 左右 两个平移的程序,现在想合成一个,但是cond这个东西不好弄,越搞越糊涂向大家请教一下,该如何完善!
(defun c:MoveIt (/ ss d dir ang i e rot)
(setq ss (ssget ":L" '((0 . "TEXT,MTEXT"))))
(setq d (getdist "\nSpecify offset distance: "))
(initget "L R U D")
(setq dir
(cond
(getkword "\nChoose direction [上下左右] <右/R>:")
(if (NULL dir) (setq dir "R")
)
(t dir)
)
)
(cond ((= dir "U")(setq ang (/ pi 2) ))
((= dir "R")(setq ang0))
((= dir "D")(setq ang (* 3 (/ pi 2)) ) )
((= dir "L")(setq ang pi))
)
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(setq rot (vlax-get e 'Rotation) ip (vlax-get e 'InsertionPoint))
(Vlax-put e 'InsertionPoint (polar ip (+ ang rot) d)
)
)
(princ)
)
(defun c:MoveIt (/ ang d dir e i ip rot ss)
(setq ss (ssget ":L" '((0 . "TEXT,MTEXT"))))
(setq d (getdist "\nSpecify offset distance: "))
(while d
(initget "L R U D")
(setq dir (getkword "\nChoose direction [上(U)/下(D)/左(L)/右(R)] <右/R>:"))
(if (NULL dir) (setq dir "R"))
(cond ((= dir "U")(setq ang (/ pi 2) ))
((= dir "R")(setq ang0))
((= dir "D")(setq ang (* 3 (/ pi 2)) ) )
((= dir "L")(setq ang pi))
)
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(setq rot (vlax-get e 'Rotation) ip (vlax-get e 'InsertionPoint))
(Vlax-put e 'InsertionPoint (polar ip (+ ang rot) d)
)
))
(princ)
)
弄明白就是很简单的 start4444 发表于 2023-5-31 10:50
(defun c:MoveIt (/ ang d dir e i ip rot ss)
(setq ss (ssget "" '((0 . "TEXT,MTEXT"))))
(setq d ...
谢谢楼上的兄弟,又学习了while和cond!
页:
[1]