AutoCAD运行AutoLisp代码报“;; error: no function definition: [DEFINE”错误求助
AutoCAD AutoLisp报错“;; error: no function definition: [DEFINE”的含义与解决方法
报错含义
这个错误是因为代码里出现了AutoLisp解释器无法识别的[define符号——AutoLisp将它当成了一个需要调用的函数,但实际上不存在名为[DEFINE的内置或自定义函数,因此抛出“无函数定义”的错误。
解决方法
问题根源在你代码中的[define program]行:这是非法的注释写法,AutoLisp不支持用方括号包裹注释。你需要将这行改为合法的AutoLisp注释(以分号;开头),或者直接删除它。
修正后的代码
(defun C:DDs( ; define program (setq a (getstring "Qty? ")) (setq b (getstring "Lot? ")) (if (= a b) (progn (princ "HoHoH ") );end progn (progn (princ "Hihihii") );end progn );end if )
如果想简化代码(单个语句的if分支不需要progn),可以写成:
(defun C:DDs( ; define program (setq a (getstring "Qty? ")) (setq b (getstring "Lot? ")) (if (= a b) (princ "HoHoH ") (princ "Hihihii") ) )
内容的提问来源于stack exchange,提问作者fevera13
相关产品推荐
相关产品推荐

