明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: yuncai11

编程中遇到函数错误提示是怎么回事?

  [复制链接]
发表于 2004-6-1 13:03:00 | 显示全部楼层
还有,子函数中如果设置成了局部变量,在主函数中是不可以使用了,如jiansuo函数中的s h等
 楼主| 发表于 2004-6-1 13:11:00 | 显示全部楼层
对啊我在调试的时候发现了这个问题


是不是把他们全都设成全局变量呢?
发表于 2004-6-1 13:13:00 | 显示全部楼层
先看下面这个,要看完了,,,http://bbs.mjtd.com/forum.php?mod=viewthread&tid=21383再看我给你改的程序。。。注意,你的程序,最后command部分是错误的,所以程序无法完成,这部分我未改,注意subtract命令的用法。。。
  1. (defun jiansuo (ct / f1 p)
  2.    (setq f1 (open "e:\\abc.txt" "r"))
  3.    (repeat ct
  4.        (setq p (read (read-line f1)))
  5.    )
  6.    (close f1)
  7.    p
  8. )         
  9. (defun c:luos1 (/ lst item l d ct p p1 ent_p ent_c)
  10.    (setq lst '((10 20 200) (12 25 260) (14 25 260) (16 30 300) (18 35 300)
  11.              (20 35 300) (22 50 300) (24 55 300) (27 60 300) (30 60 300)
  12.              (36 80 300) (42 80 300) (48 110 300) (56 160 380) (64 180 380)
  13.              (72 180 380) (80 200 380)(90 220 500) (100 220 500)))
  14.    (while (not (assoc (setq d (getreal "\n请输入螺栓的直径:")) lst)))
  15.    (setq item (assoc d lst))
  16.    (setq l (getreal (strcat "\n请输入螺栓的长度在" (rtos (cadr item)) "到" (rtos (last item)) "之间:")))
  17.    (if (and (> l (- (cadr item) 0.01)) (< l (- (caddr item) 0.01)))
  18.        (progn
  19.            (setq ct (1+ (- (length lst) (length (member item lst)))))
  20.            (setq lst (jiansuo ct))
  21.            (cond ((< l 125.01) (setq l0 (+ (* d 2) 6)))
  22.          ((or (> l 125) (< l 200.01)) (setq l0 (+ (* d 2) 12)))
  23.          ((> l 200) (setq l0 (+ (* d 2) 25)))
  24.            )
  25.            (setq p (getpoint "\n请输入图形的插入点:"))
  26.            (command "polygon" 5 p "c" (nth 0 lst))
  27.            (setq ent_p (entlast))
  28.            (command "subtract" ent_p "" (nth 1 lst) "")
  29.            (setq p1 (list (car p) (cadr p) (nth 1 lst)))
  30.            (command "ucs" "n" p1)
  31.            (command "circle" p1 d)
  32.            (setq ent_c (entlast))
  33.            (command "subsrtact" ent_c "" l "")
  34.        )
  35.    )
  36.    (princ)
  37. )
 楼主| 发表于 2004-6-1 13:20:00 | 显示全部楼层
多谢大侠拔刀相助。我会常来看你的


呵呵
 楼主| 发表于 2004-6-1 13:22:00 | 显示全部楼层
呵呵我在拉伸的时候用了subtract本来想用extrude
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-1 08:15 , Processed in 0.165964 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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