检查输入字段是否已读取
大家好,我有一个问题,我似乎无法通过谷歌来解决。
我是一个非常基本的autocad程序员,所以请容忍我。
我有一个简单的小代码来填充DWGPROPS的作者,以自动填充我的标题栏。就像一个符咒,但我想添加一个检查,看看它是否已经填写,这样我可以自动打开一个绘图,这样当其他人打开它时,它不会覆盖原始作者。
我没有收到任何错误信息或反馈,所以我不知道如何继续,所以希望你们中的任何人都能帮助我。
这是代码:
(defun C:Author (/ doc db si author)
(vl-load-com)
(setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq db (vla-get-Database doc))
(setq si (vla-get-SummaryInfo db))
(setq ath (getenv "username"))
(setq ath_first(substr ath 1 2))
(setq ath_last(substr ath 3))
(setq Hath (strcat (strcase ath_first) ath_last))
(while (setq Ennt 0)
(cond
((= Entt 0)
(vla-put-author si Hath)
(setq Ennt 1+)
)
);cond
);while put的对面是get(vla get author si),然后检查是否为空。 我用你的“get”试过了,但我的知识有限
仍然没有显示任何错误
(while
(cond (setq check (vla-get-author si))
((= check "")
(vla-put-author si Hath)
)
);cond
);while 谢谢Bigal,
发现问题
将变量放置在错误的位置。
如果有人能用的话,给你
(defun C:Author (/ doc db si author)
(vl-load-com)
(setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(setq db (vla-get-Database doc))
(setq si (vla-get-SummaryInfo db))
(setq ath (getenv "username"))
(setq ath_first(substr ath 1 2))
(setq check (vla-get-author si))
(setq ath_last(substr ath 3))
(setq Hath (strcat (strcase ath_first) ath_last))
(while
(cond
((= check "")
(vla-put-author si Hath)
)
);cond
);while
);defun
上下快速移动 您的(while)
(while
(cond
((= check "")
(vla-put-author si Hath)
)
);cond
);while
mine
(if (= check "")(vla-put-author si Hath))
哦,真的,
我在一些Autocad lisp库中读到,当使用“If”函数时,它需要一个“else”。
如果没有“else”,则使用“while”函数。
很高兴知道,谢谢 你还使用了while和cond进行了双重检查
页:
[1]