autolisp中的画线命令

来源:百度知道 编辑:UC知道 时间:2024/05/28 17:49:04
(defun C: trin()
(setq p1 (getPoint))
(setq p2 (getPoint))
(setq p3 (getPoint))
(command "line" p1 p2 p3 "c")
)
照着教程抄下来的,为什么错误 哪里格式有问题
嗯,我输入了点坐标之后,提示说未知命令"LINE","C"

使用autolisp程序绘制图形,必须是写好正确的程序后,检查无误后加载成功后才可以运行,再根据cad的命令行的提示操作,才可以生产正确的图形。
你这个程序是画一个三角形,最后的(command “line” p1 p2 p3 “C”)意思是执行autocad的绘图命令:line,然后从P1到P2,P2到P3各画一条直线。最后的“C”意思是“close”,并不是楼上说的画圆的命令。
我给你修改一下你的程序清单吧,你再试试。
;this program will prompt you to enter three points
;of a triangle from the keyboard ,or select three points
;by using the screen cursor .P1,P2,P3 are triangle corners

(defun: C:triang1()
(setq p1(getPoint“\n Enter first Point of triangle:”))
(setq p2(getPoint“\n Enter second Point of triangle:”))
(setq p3(getPoint“\n Enter third Point of triangle:”))
(Command“line” p1 p2 p3“C”)

以上是我运行成功的程序。你一定输入正确,正确加载后,根据命令行的提示分别先后选取三个点后就可以生成三角形了。注意三角形的形成条件是:两边之和大于第三边,两边之和小于第三边的哦。不要乱选三个点。注意保存是一定要目录正确,还有lsp这个扩展名不能省略掉啊!!
祝你成功!

getPoint是让你定点的意思,你没有定义P1 P2 P3 点的位置 所以打(command "line" p1 p2 p3 "c") 时连线连不出P1 P2 P3