You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AutoLisp中如何获取变量值列表而非变量名称列表?

问题原因

你代码里的 '(count xp yp zp) 使用了单引号('),在Lisp中这会阻止括号内的符号被求值,所以cenPT存储的是变量名称组成的符号列表,而非变量对应的值。

解决方法

要获取变量的值并组成列表,需要使用list函数,它会对每个传入的参数求值,再将结果组合成列表:

(defun c:loop3 ()
    (setq xp 5)
    (setq count 0)
    (setq zp 200)
    
    (setq yp 5)
    (setq cenPT (list count xp yp zp)) ; 替换单引号列表为list函数调用
    (princ cenPT)
    (princ)
)

运行修改后的代码,cenPT会被赋值为(0 5 5 200),用princ输出时就会显示变量对应的值了。

内容的提问来源于stack exchange,提问作者coco

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 09:45:33