从文件读坐标绘制多义线问题
<p>从txt文件中逐个读入坐标值,每次只能读进了一个坐标值,然后调用pline,但不能继续循环下去,</p><p>请高手指点,这是我的代码:</p><p>(defun c:bianxing()<br/> (setq oldcmd (getvar "cmdecho")) <br/> (setvar "cmdecho" 0) <br/> (setq oldblip (getvar "blipmode")) <br/> (setvar "blipmode" 0) <br/> (setq oldsnap (getvar "osmode")) <br/> (setvar "osmode" 0) <br/> (setq rr (getfiled "请选择变形数据文件" "a0" "txt;dat;*" 8)) <br/> (setq rr1 (open rr "r"))<br/>(while (setq coor (read-line rr1)) ;循环读取每一行<br/> (setq coor (read-line rr1))<br/> (setq coor0 (read (strcat "(" coor ")")))<br/> (command "pline" coor0)<br/> )<br/> )</p> <p><font color="#ff6666">(while (setq coor (read-line rr1)) ;循环读取每一行<br/> (setq coor (read-line rr1))<br/> (setq coor0 (read (strcat "(" coor ")")))<br/> (command "pline" coor0)<br/> )</font></p><p><font color="#ff6666">改成<br/></font><font color="#ff6666"><font color="#000000">(command "pline")<br/></font></font><font color="#ff6666"><font color="#000000">(while (setq coor (read-line rr1)) ;循环读取每一行<br/> (setq coor (read-line rr1))<br/> (setq coor0 (read (strcat "(" coor ")")))<br/> (command coor0)<br/> )<br/>(command "")</font></font><font color="#ff6666"><br/><br/></font></p> (defun c:bianxing (/ oldcmd oldblip oldsnap rr rr1 coor)(setq oldcmd (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq oldblip (getvar "blipmode"))
(setvar "blipmode" 0)
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)
(setq rr (getfiled "请选择变形数据文件" "a0" "txt;dat;*" 8))
(setq rr1 (open rr "r"))
(command "_.pline")
(while (setq coor (read-line rr1)) ;循环读取每一行
(command coor)
) ;_ 结束while
(command "")
(close rr1)
) ;_ 结束defunDAT文件格式:
5,5
6,6
7,65
78.12,458
非常感谢楼上两位,感激涕零 <p>再请教一下,我现在是做的的两个文件中数值所计算后的数值作为坐标,来画线。</p><p>为什么楼上的加上 (command "c")就可以曲线闭合,而下面的代码就不行呢,帮我看看问题所在,谢谢<br/>(defun c:bianxing()<br/> (setq oldcmd (getvar "cmdecho")) <br/> (setvar "cmdecho" 0) <br/> (setq oldblip (getvar "blipmode")) <br/> (setvar "blipmode" 0) <br/> (setq oldsnap (getvar "osmode")) <br/> (setvar "osmode" 0) <br/> (setq rr (getfiled "请选择变形数据文件" "a0" "txt;dat;*" 8)) <br/> (setq rr1 (open rr "r"))<br/> (setq ff (getfiled "请选择变形数据文件" "a2" "txt;dat;*" 8)) <br/> (setq ff1 (open ff "r"))</p><p> (command "pline" )<br/> (while (setq data (read-line ff1)) ;循环读取每一行<br/> (setq aa (strcat "(" data ")"));用来检测读出的数据格式<br/> (setq bb (read aa)) ;用来检测读出的数据格式 <br/> (setq data (read (strcat "(" data ")")))<br/> (setq number (car bb)<br/> neirong (cadr bb ))<br/> (setq coor (read-line rr1))<br/> (setq coor (read (strcat "(" coor ")")))<br/> (setq xx (car coor)<br/> yy (cadr coor))<br/> (setq xx1 (+ xx number)<br/> yy1 (+ yy neirong))<br/> (setq coor1 (list xx1 yy1))<br/> (command coor1)<br/> ) <br/> (command "c")<br/> <br/> (prin1)<br/>)<br/></p><p></p> 问题已经解决,是数据文件的末尾有几个回车的原因 sailorcwx 发表于 2007-6-3 15:48
(while (setq coor (read-line rr1)) ;循环读取每一行 (setq coor (read-line rr1 ...
真好,看似简单,正到用时,因为一点点小问题就寸步难行。感谢感谢
页:
[1]