Lt Dan's l 发表于 2022-7-6 10:37:31

cond和重复com帮助

我只是想知道怎么做。。
 
(defun C:test (/)
(setq ss (ssget))
(command "_.erase" ss "")
(setq p1 (getpoint "\n**First point**"))
(setq p2 (getpoint p1 "\n**Second point**"))
(command "_.line" p1 p2 nil)
(setq opt (strcase (getstring "\NRepeat Last Command <Yes or No>: ")))
(cond((or(= opt "Y")(= opt "YES"))(prompt "\nrepeat last command"))
;;instead of prompting repeat last command I want it to actually repeat it
          (T (prompt "\nExiting command"))
)
(princ)
)

alanjt 发表于 2022-7-6 10:43:31

这就是你想要实现的吗?
 
(defun c:Test (/ ss p1 p2)
(if (setq ss (ssget "_:L"))
   (progn
   (command "_.erase" ss "")
   (while (and (setq p1 (getpoint "\nSpecify first point: "))
               (setq p2 (getpoint p1 "\nSpecify second point: "))
            )
       (command "_.line" "_non" p1 "_non" p2 "")
   )
   )
)
(princ)
)

rkmcswain 发表于 2022-7-6 10:44:05

不确定你想重复哪一部分,但这里有一种方法。。。。
 


(defun C:test (/)
(setq ss (ssget))
(command "_.erase" ss "")
(setq wait T)
(while wait
   (setq p1 (getpoint "\n**First point**"))
   (setq p2 (getpoint p1 "\n**Second point**"))
   (command "_.line" p1 p2 nil)
   (initget 1 "Y N")
   (setq opt (getkword "\nRepeat Last Command : "))
   (if (eq "N" opt)
   (setq wait nil)
   )
)
(princ)
)

Lt Dan's l 发表于 2022-7-6 10:47:57

 
看起来你有。午饭后我会测试。

asos2000 发表于 2022-7-6 10:51:27

对于initget
使用
(initget 1 "Y N")
(setq opt (getkword "\nRepeat Last Command /No]: "))
 
而不是
(initget 1 "Y N")
(setq opt (getkword "\nRepeat Last Command or No]: "))
 
显示菜单(见附件)

Lt Dan's l 发表于 2022-7-6 10:56:05

好吧,我给!!
 
如何检索块旋转?
(setq ss (ssget "_:s" '((0 . "insert"))))
;;not really knowledgeable on assoc or car functions
;;I did find that rotation = 50

Lee Mac 发表于 2022-7-6 10:59:42

1) 检查有效的选择集:
 
(if (setq ss (ssget '((0 . "INSERT"))))
...
 
2) 迭代选择集:
 
最直观的可能是:
 

(setq counter 0)
(repeat (sslength ss)
(setq ent (ssname ss counter))
...
(setq counter (1+ counter))
)

 
3) 查询每个实体的旋转:
 
(cdr (assoc 50 (entget ent)))

Lt Dan's l 发表于 2022-7-6 11:02:33

 
 
谢谢你,先生

Lt Dan's l 发表于 2022-7-6 11:04:09

旋转是50吗?我得到了一些奇怪的角度。。。

alanjt 发表于 2022-7-6 11:07:44

它将以弧度为单位。
页: [1] 2
查看完整版本: cond和重复com帮助