明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1629|回复: 9

autolisp新手请大家帮着看看这个提取数据的程序,这个程序执行时,老是出不来结果

[复制链接]
发表于 2005-5-24 12:04:00 | 显示全部楼层 |阅读模式
我是一个autolisp新手,这个程序可以成功加载,但是老是不出结果,请大家帮我看看,万分感谢!
发表于 2005-5-24 12:49:00 | 显示全部楼层
程序在哪里?
 楼主| 发表于 2005-5-25 19:27:00 | 显示全部楼层

本帖子中包含更多资源

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

x
发表于 2005-5-26 17:32:00 | 显示全部楼层
给你改了一份,你自己比较吧,呵呵,主要是函数用法不清楚和数据类型错误
发表于 2005-5-26 17:39:00 | 显示全部楼层
郁闷,传不上去,晕,只是简单的改了改,能实现你的要求了,别的方面自己改吧 (defun c:getdata ()
(setq bp (getpoint " 基点"))
(setq L (getreal "L"))
(setq D (getreal "D"))
(setq x1 (nth 0 bp))
(setq y1 (nth 1 bp))
(setq p1 (list x1 y1))
(setq p2 (list x1 (+ y1 (+ L L))))
(setq p3 (list (+ x1 L) (+ y1 (+ L L))))
(setq p4 (list (+ x1 L) y1))
(setq p5 (list (+ x1 L) (+ y1 L)))
(command "line" p1 p2 "")
(command "line" p2 p3 "")
(command "ARC" p4 "C" P5 p3 "")
(command "line" p4 p1 "")
(command "CIRCLE" p5 "D" D "")
(PRIN1)
(setq st (ssget))
(setq n 0)
(setq f (open "c:/data.txt" "w"))
(setq len (sslength st))
(while (< n len)
(setq e (ssname st n))
(setq el (entget e))
(setq objtype (cdr (assoc 0 el)))
(if
(= "LINE" objtype)
(progn
(setq p1-x (nth 0 (cdr (assoc 10 el))))
(setq p1-y (nth 1 (cdr (assoc 10 el))))
(setq p1-z (nth 2 (cdr (assoc 10 el))))
(setq p2-x (nth 0 (cdr (assoc 11 el))))
(setq p2-y (nth 1 (cdr (assoc 11 el))))
(setq p2-z (nth 2 (cdr (assoc 11 el))))
(setq p1 (strcat (rtos p1-x) "," (rtos p1-y) "," (rtos p1-z)))
(setq p2 (strcat (rtos p2-x) "," (rtos p2-y) "," (rtos p2-z)))
(write-line "l:" f)
(write-line "the start point is:" f)
(write-line p1 f)
(write-line "the end piont is:" f)
(write-line p2 f)
)
) (if (= "ARC" objtype)
(progn (setq p-x (nth 0 (cdr (assoc 10 el))))
(setq p-y (nth 1 (cdr (assoc 10 el))))
(setq p-z (nth 2 (cdr (assoc 10 el))))
(setq r (cdr (assoc 40 el)))
(setq r (rtos r))
(setq sangle (cdr (assoc 50 el)))
(setq sangle (rtos sangle))
(setq eangle (cdr (assoc 51 el)))
(setq eangle (rtos eangle))
(setq p (strcat (rtos p-x) "," (rtos p-y) "," (rtos p-z)))
(write-line "arc:" f)
(write-line "the center piont is:" f)
(write-line P f)
(write-line "the start angle is:" f)
(write-line sangle f)
(write-line "the end angle is:" f)
(write-line eangle f)
(write-line "the radios is:" f)
(write-line r f)
)
) (if (= "CIRCLE" objtype)
(progn
(setq p-x (nth 0 (cdr (assoc 10 el))))
(setq p-y (nth 1 (cdr (assoc 10 el))))
(setq p-z (nth 2 (cdr (assoc 10 el))))
(setq r (cdr (assoc 40 el)))
(setq r (rtos r))
(setq p (strcat (rtos p-x) "," (rtos p-y) "," (rtos p-z)))
(write-line "circle:" f)
(write-line "the center piont is:" f)
(write-line P f)
(write-line "the radios is:" f)
(write-line r f)
) )
(setq n (1+ n))
)
(close f)
)
 楼主| 发表于 2005-5-26 22:00:00 | 显示全部楼层
十分感谢“山高人为峰”的指点,第一次上论坛求助,就能获得指点,真的很高兴!


这个程序我又改了改,去掉了中间的prin1函数那行,才能运行出结果,但仍然提示参数类型错误,不知道为什么?而且关于这个程序我还想请教三个问题:


1、prin1函数不可在程序中间采用吗?


2、progn函数怎么用?


3、提取数据时系统如何确定图元顺序,可否用程序对其进行顺序控制?
发表于 2005-5-27 09:06:00 | 显示全部楼层
不是丫,不用去prin1也可以运行呀,还有最好改成princ,


progn函数是跟在if后面的(if (判断试) (符合后运行)),但是这样运行程序只能运行一句,而progn就可以把多句用一个括号括起,还不清楚的话去帮助文件里看看吧


第三个问题不明白
发表于 2005-5-27 09:22:00 | 显示全部楼层
图元的顺序是按起生成的先后顺序的,你要控制,只能先自己排好序后,再重新生成图元
发表于 2005-5-27 14:40:00 | 显示全部楼层
谁送我的鲜花呀,嘻嘻,谢谢了
发表于 2005-5-27 22:54:00 | 显示全部楼层
meflying发表于2005-5-27 9:22:00图元的顺序是按起生成的先后顺序的,你要控制,只能先自己排好序后,再重新生成图元

如果要将该图员对应的某个参数改变,可以怎样动态的控制?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-17 11:22 , Processed in 0.180267 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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