明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1369|回复: 7

[基础] 关于参数类型的问题

[复制链接]
发表于 2011-4-14 10:11:28 | 显示全部楼层 |阅读模式
各位大侠,请看下面的程序:
(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来获取实体和点的,可是程序走到这一步总是提示参数类型错误,并返回点坐标,所以我想问下各位,坐标参数类型到底出错在哪里,谢谢啦~~~
 楼主| 发表于 2011-4-14 10:28:19 | 显示全部楼层
补充一下, 我刚才通过监视看到
(setq x(car pt))中,x并未得到pt的横坐标,而是得到了pt的全部坐标,这是为什么呢?难道与entsel有关么?
发表于 2011-4-14 10:43:30 | 显示全部楼层
(setq pt (cdr s))
===>
(setq pt (cadr s))
 楼主| 发表于 2011-4-14 10:47:12 | 显示全部楼层
回复 Andyhon 的帖子

你好,我试了一下, 返回参数类型错误consp+数字,额,不知道是什么原因啊
发表于 2011-4-14 10:56:45 | 显示全部楼层
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)
 楼主| 发表于 2011-4-14 12:12:06 | 显示全部楼层
回复 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.
发表于 2011-4-14 14:55:14 | 显示全部楼层
(command "text" "m" pt h1 0 sxh1)
===>
(command "text" "m" "None" pt h1 0 sxh1)
 楼主| 发表于 2011-4-14 20:37:59 | 显示全部楼层
回复 Andyhon 的帖子

Thank you very much!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-6-10 13:18 , Processed in 0.177098 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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