关于参数类型的问题
各位大侠,请看下面的程序:(princ "\n*********长度标注与量算***********")
(defun c:hh (/pt x y pt b c jj file file_obj qz sxh1 h1 n1 s o)
(setvar "cmdecho" 0)
(command "-style" "BG_ST" "宋体")
(setq file (getfiled "输出长度" "" "txt" 1))
(setq file_obj(open file "w") )
(setq qz (getstring "\n请输入前缀"))
(if (not (setq n1 (getint "\n请输入起始顺序号 <1>: ")))
(setq n1 1)
)
(if (not (setq h1 (getreal "\n请指定文字高度 <2.5>: ")))
(setq h1 2.5)
)
(setq s (entsel "点线段"))
(setq o (car s))
(while o
(setq b o)
(if b
(progn
(command "lengthen" b "")
(setq c (getvar "perimeter"))
(setq jj (rtos c 2 2))
(write-line (strcat qz (rtos n1 2 0) "长度="jj ) file_obj)
(setq sxh1 (strcat qz (itoa n1)))
(setq pt (cdr s))
(setq x(car pt))
(setq x(+ x 10))
(setq y(cdr pt))
(setq pt(list x y))
(command "text" "m" pt h1 0 sxh1) (setq n1 (1+ n1))
(setq s (entsel "\n点线段:"))
(setq o (car s))
)
)
)
)
我标注红色部分,是我想在pt这一点上插入文字,我是用entsel来获取实体和点的,可是程序走到这一步总是提示参数类型错误,并返回点坐标,所以我想问下各位,坐标参数类型到底出错在哪里,谢谢啦~~~ 补充一下, 我刚才通过监视看到
(setq x(car pt))中,x并未得到pt的横坐标,而是得到了pt的全部坐标,这是为什么呢?难道与entsel有关么? (setq pt (cdr s))
===>
(setq pt (cadr s))
回复 Andyhon 的帖子
你好,我试了一下, 返回参数类型错误consp+数字,额,不知道是什么原因啊 No Problem Here
Command: (setq s (entsel))
Select object: (<Entity name: 7ef53f50> (195.109 80.6775 0.0))
Command: (cadr s)
(195.109 80.6775 0.0) 回复 Andyhon 的帖子
Thank you ,I have accomplished it. And I have a further question : in my program, you can see that I want insert some text at "pt", but when I run this program, the text appear at the beginning of the line I choose, rather than "pt", I want to know the reason . Thanks for your help. (command "text" "m" pt h1 0 sxh1)
===>
(command "text" "m" "None" pt h1 0 sxh1) 回复 Andyhon 的帖子
Thank you very much!
页:
[1]