明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1696|回复: 5

飞飞斑竹进来看看

[复制链接]
发表于 2004-6-1 22:08:00 | 显示全部楼层 |阅读模式
还是我们今天上午看的问题但是在运行是 参数类型错误: consp nil提示 程序如下:(defun jiansuo (ct / f1 p)
(setq f1 (open "c:\\data\\luos1.txt" "r"))
(repeat ct
(setq p (read (read-line f1)))
(princ p)
)
(close f1)
)
;(defun c:luos1 (/ lst item l d ct p p1 ent_p ent_c lst2)
(setq lst '((10 20 200) (12 25 260) (14 25 260) (16 30 300) (18 35 300)
(20 35 300) (22 50 300) (24 55 300) (27 60 300) (30 60 300)
(36 80 300) (42 80 300) (48 110 300) (56 160 380) (64 180 380)
(72 180 380) (80 200 380)(90 220 500) (100 220 500)))
(while (not (assoc (setq d (getreal "\n请输入螺栓的直径:")) lst)))
(setq item (assoc d lst))
(setq l (getreal (strcat "\n请输入螺栓的长度在" (rtos (cadr item)) "到" (rtos (last item)) "之间:")))

(if (and (>= l (cadr item) ) (<= l (caddr item)))
(progn
(setq ct (1+ (- (length lst) (length (member item lst)))))
(princ ct)
(setq lst2 (jiansuo ct))
(princ lst2)
(setq s (nth 0 lst2)
h (nth 1 lst2)
r (nth 2 lst2)
d1 (nth 3 lst2))

(cond ((<= l 125) (setq l0 (+ (* d 2) 6)))
((or (> l 125) (<= l 200)) (setq l0 (+ (* d 2) 12)))
((> l 200) (setq l0 (+ (* d 2) 25)))
)
(setq p (getpoint "\n请输入图形的插入点:"))
(command "polygon" 5 p "c" s)
(setq ent_p (entlast))
(command "extrude" ent_p "" l "")
(setq p1 (list (car p) (cadr p) h))
(command "ucs" "n" p1)
(command "circle" p1 d)
(setq ent_c (entlast))
(command "extrude" ent_c "" l "")
)
)
(princ)
;) 这个是luos1的内容
(17 7 0.5 19.6)
(19 8 0.8 21.9)
(22 9 0.8 25.4)
(24 10 1 27.7)
(27 12 1 31.2)
(30 13 1 34.6)
(32 14 1 36.9)
(36 15 1.5 41.6)
(41 17 1.5 47.3)
(46 19 1.5 53.1)
(55 23 2 63.5)
(65 26 2 75)
(75 30 2 86.5)
(85 35 2 98)
(95 40 3 109)
(105 45 3 120)
(115 50 3 132)
(130 57 3 150)
(145 63 3 167)
 楼主| 发表于 2004-6-1 22:11:00 | 显示全部楼层
我分析了一下还是在调用外部文件数据时没有返回数据,我下面要用到这些数据不是LST的数据LST的只是用来判断的。
 楼主| 发表于 2004-6-1 22:17:00 | 显示全部楼层
我想在函数中的jiansuo的返回数值应该是p的数值而且p的值赋给LST2才对。为什么出现错误呢??
发表于 2004-6-1 22:23:00 | 显示全部楼层
你为什么把我的jiansuo函数该你呢,你这个函数的最后一个表达式是(close f1),而这个函数正常情况下返回nil,所以你不会返回读取的p值了,看看我写的那个,最后有一个单独的p,,,,


另外,建议你看一下帮助文件中关于Vlisp编辑器部分,跟踪一下错误出在什么地方,这样一般的问题只要知道问题出在哪儿,就很容易看出来问题是什么的
 楼主| 发表于 2004-6-2 07:46:00 | 显示全部楼层
呵呵 原来哪个p还很有用的我觉得突然来了个p 好象没用就个删了


多谢了
发表于 2004-6-2 13:37:00 | 显示全部楼层
.那是为了函数有返回值,否则返回的是(close f1)的结果nil.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-10-1 06:12 , Processed in 0.161937 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表