明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1118|回复: 6

[已解答] 利用while和存好的数据文件实现连续画直线

[复制链接]
发表于 2015-4-25 21:40:52 | 显示全部楼层 |阅读模式
(defun C:b()
  (setq filepath(findfile "test7.txt"))
  (setq f (open filepath "r"))
  (setq str (read-line f))
  
  (while str
     (setq pt (read str))
     (command "line" pt )
     (setq str (read-line f))

   )
  (close f)

)  
想法:例如存好的文件,想通过程序把这些点依次连起来。上面是我自己的代码,划线部分不知道怎么弄,求大神指教
(0 1)
(1 4)
(2 6)
(3 12)
(4 5)
 楼主| 发表于 2015-4-25 21:41:27 | 显示全部楼层
自己先顶一下
发表于 2015-4-25 21:52:20 | 显示全部楼层
  1. ;读取文件夹里面的字符串生成表
  2. (defun cx-read (txt_str / str_lst ff data)
  3.   (setq str_lst nil)
  4.   (if (setq ff (open txt_str "r"))
  5.     (progn
  6.       (while (setq data (read-line ff))
  7.                                 (setq str_lst (cons data str_lst))
  8.       )
  9.       (close ff)
  10.     )
  11.   )
  12.   str_lst
  13. )
 楼主| 发表于 2015-4-25 22:05:40 | 显示全部楼层
鱼与熊掌 发表于 2015-4-25 21:52

thanks,主要是怎么画多段线

点评

将楼下院长的程序中line改成pline就行了。  发表于 2015-4-26 09:51
发表于 2015-4-25 23:16:34 | 显示全部楼层
  1. (defun c:tt ()
  2.   (if (setq fl (findfile "test7.txt"))
  3.     (progn
  4.       (setq fp (open fl "r"))
  5.       (command "line")
  6.       (while (setq pt (read-line fp))
  7.         (command (read pt))
  8.       )
  9.       (command "")
  10.       (close f)
  11.     )
  12.   )
  13.   (princ)
  14. )

评分

参与人数 1明经币 +1 收起 理由
shirleyklove + 1 很给力!

查看全部评分

 楼主| 发表于 2015-4-26 22:17:16 | 显示全部楼层
xyp1964 发表于 2015-4-25 23:16

非常感谢,我也慢慢学习
 楼主| 发表于 2015-4-26 22:46:30 | 显示全部楼层
shirleyklove 发表于 2015-4-25 22:05
thanks,主要是怎么画多段线

line也可以画,
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-22 04:16 , Processed in 0.169294 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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