找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 779|回复: 2

[LISP程序]:请教各位大侠,这个程序错在哪里

[复制链接]
发表于 2006-5-26 12:27:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
(defun C:guo()
(initget 7)
(setq ty (getstring "please input type<t1/t2/t3/t4>:"))
  (setq f1 (open "G:guo.txt" "r"))
  (setq r1 (read-line f1))
  (setq b1 (read (strcat "(" r1 ")")))
  (setq k 0)
    (while (/= k nil)
      (setq sj (read (strcat "(" read-line f1) ")")))
      (if (= (read ty) (nth 0 sj)) (setq k nil))
    );while end
    (close f1)
  (setq len (length b1));the length of list
   (setq n 0)
     (repeat len
      (set (nth n b1) (nth n sj))
      (setq n (+ n 1))
     );repeat end
(cond ((=ty "t1") (setq pr'(0 0)))
       ((=ty "t2") (setq pr'(0 0)))
       ((=ty "t3") (setq pr'(0 0)))
       ((=ty "t4") (setq pr'(0 0)))
)

(setq category 1)
(setq m_diameter 0)
(setq m_length 0)

(command "layer" "m" "0" "ON" "0" "L" "continuous" "0" "")
(setq temp_x (car pt0))
(setq temp_y (cadr pt0))
(setq pt1 (list (- temp_x m_chamferB) (+ temp_y (/ m_diameter 2))))
(setq tan (/ (sin (dtr m_chamferA)) (cos (dtr m_chamferA))))
(setq temp (* tan m_chamferB))
(setq pt2 (polar pt1 (* -0.5 pi) temp))
(setq pt2 (polar pt2 (* -1 pi) m_chamferB))
(command "pline" pt1 pt2 pt0"")
(setq ob1 (entlast))
(command "mirror" ob1 "" pt0 (list (+ temp_x 10) temp_y) "")
(setq ob2 (entlast))
(setq pt3 (list (- temp_x m_length) (- temp_y (/ m_diameter 2))))
(command "rectang" pt1 pt3)
(setq ob3 (entlast))
(command "layer" "m" "2" "ON" "2" "c" "red" "2" "L" "center" "2" "")
(command "line" (polar pt0 (* -1 pi) (/ m_diameter 8)) (polar pt0 0 (+ m_length (/ m_diameter 8))) "")
(setq ob4 (entlast))
(if (= m_direction 0)
  (progn
   (command "mirror" ob1 ob2 ob3 ob4 "" pt0 pt2 "Y")
   (setq ob5 (entlast))
   (command "move" ob1 ob2 ob3 ob4 ob5 "" pt0 (polar pt0 0 m_length))
  ))
(setq pt00 (polar pt0 0 m_length))

(command "layer" "m" "0" "ON" "0" "L" "continuous" "0" "")
(setq temp_xx (car pt00))
(setq temp_yy (cadr pt00))
(setq pt4 (list (+ temp_xx m_chamferB) (+ temp_yy (/ m_diameter 2))))
(setq tan (/ (sin (dtr m_chamferA)) (cos (dtr m_chamferA))))
(setq temp (* tan m_chamferB))
(setq pt5 (polar pt4 (* -0.5 pi) temp))
(setq pt5 (polar pt5 (* -1 pi) m_chamferB))
(command "pline" pt4 pt5 pt00"")
(setq ob6 (entlast))
; (command "_chamfer" "A" m_chamferB m_chamferA "")
; (command "_chamfer" "P" object1 "" "")
(command "mirror" ob6 "" pt00 (list (+ temp_xx 10) temp_yy) "")
(setq ob7 (entlast))
(setq pt6 (list (+ temp_xx (-m_length m_chamferB)) (- temp_yy (/ m_diameter 2))))
(command "rectang" pt4 pt6)
(setq pt7 (list (+ temp_xx (/ m_length 2)) (+ temp_yy (/ m_diameter 2))))
(setq pt8 (list (+ temp_xx (/ m_length 2)) (- temp_yy (/ m_diameter 2))))
(command "mirror" ob6 ob7 "" pt7 pt8 "")
(command "layer" "m" "2" "ON" "2" "c" "red" "2" "L" "center" "2" "")
(setq pt9 (list (- (car pt4) m_chamferB) (- (cadr pt4) (/ m_chamferB 2))))
(setq pt10 (polar pt9 0 m_length))
(command "line" pt9 pt10 "")
(setq ob7 (entlast))
(command "mirror" ob7 "" pt00 (polar pt00 0 10) "")
(command "line" (polar pt00 (* -1 pi) (/ m_diameter 8)) (polar pt00 0 (+ m_length (/ m_diameter 8))) "")
(setq pt000 (list (+ temp_xx m_length) temp_yy))

(command "layer" "m" "0" "ON" "0" "L" "continuous" "0" "")
(setq temp_xxx (car pt000))
(setq temp_yyy (cadr pt000))
(setq point1 (list temp_xxx (+ temp_yyy (/ m_diameter 2))))
(setq point2 (list (+ temp_xxx m_length) (- temp_yyy (/ m_diameter 2))))
(command "rectang" point1 point2)
(command "layer" "m" "2" "ON" "2" "c" "red" "2" "L" "center" "2" "")
(command "line" (polar pt000 (* -1 pi) (/ m_diameter 8)) (polar pt000 0 (+ m_length (/ m_diameter 8))) "")
(setq pt0000 (list (+ temp_xxx m_length) temp_yyy))

(command "layer" "m" "0" "ON" "0" "L" "continuous" "0" "")
(setq temp_xxxx (car pt0000))
(setq temp_yyyy (cadr pt0000))
(setq pt11 (list (+ temp_xxxx m_chamferB) (+ temp_yyyy (/ m_diameter 2))))
(setq tan (/ (sin (dtr m_chamferA)) (cos (dtr m_chamferA))))
(setq temp (* tan m_chamferB))
(setq pt12 (polar pt11 (* -0.5 pi) temp))
(setq pt12 (polar pt12 (* -1 pi) m_chamferB))
(command "pline" pt11 pt12 pt0000"")
(setq ob8 (entlast))
(command "mirror" ob8 "" pt0000 (list (+ temp_xxxx 10) temp_yyyy) "")
(setq ob9 (entlast))
(setq pt13 (list (+ temp_xxxx m_length) (- temp_yyyy (/ m_diameter 2))))
(command "rectang" pt11 pt13)
(setq ob10 (entlast))
(command "layer" "m" "2" "ON" "2" "c" "red" "2" "L" "center" "2" "")
(command "line" (polar pt0000 (* -1 pi) (/ m_diameter 8)) (polar pt0000 0 (+ m_length (/ m_diameter 8))) "")
(setq ob11 (entlast))
(if (= m_direction 0)
  (progn
   (command "mirror" ob8 ob9 ob10 ob11 "" pt0000 pt12 "Y")
   (setq ob12 (entlast))
   (command "move" ob8 ob9 ob10 ob11 ob12 "" pt0000 (polar pt0000 0 m_length))
  ))
(command "layer" "m" "0" "ON" "0" "L" "continuous" "0" "")
(princ)
)

不知道哪里有参数错误啊,望各位大侠赐教啊,小弟不胜感激!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 7235个

财富等级: 富甲天下

发表于 2006-5-26 15:24:13 | 显示全部楼层
未明所以 .....
(setq sj (read (strcat "(" read-line f1) ")")))
有可能是要改成
(setq sj (read (strcat "(" (read-line f1) ")")))
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-5-26 15:26:26 | 显示全部楼层

回复二楼

谢谢,这是一个画轴的程序
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-18 19:49 , Processed in 0.178753 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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