明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1201|回复: 4

[讨论] 把数据表导出到excel出错!求解释,谢啦

[复制链接]
发表于 2013-5-3 14:50 | 显示全部楼层 |阅读模式
(DEFUN C:R1()
  (SETQ P0 (GETPOINT "\n 第一个数据点:"))
  (while (/= nil)
  (setq p1 (polar p0 0 80))
  (setq p2 (polar p1 0 80))
  (setq p3 (polar p2 0 80))
  (setq p4 (polar p3 0 80))
  (setq p5 (polar p4 0 80))
    (setq ss-p (list p0 p1 p2 p3 p4 p5))
  (setq s1 (mapcar '(lambda(x)
        (setq pp (polar (polar x 0 80) (* 1.5 pi) 22))
        (setq s (ssget "c" x pp '((0 . "*text"))))
        (cdr(assoc 1 (entget (ssname s 0)))))
      ss-p
      ))
  (setq s2 (apply '(lambda (x y z x1 y1 z1)
       (strcat x "," y "," z "," x1 "," y1 "," z1)
       )
    s1
    ))
  (setq ff (open "d:\\2.csv" "w"))
  (write-line s2 ff)
  (close ff)
  (setq p0 (polar p0 (* 1.5 pi) 22))
    )
  )

总是出错!!!
数据表的每个格子大小为(长)80*(宽)22,一行为6格
发表于 2013-5-3 15:21 | 显示全部楼层
错的一塌糊涂!
(while (/= nil)
。。。
死循环了!
(setq ff (open "d:\\2.csv" "w"))
  (write-line s2 ff)
  (close ff)
文件永远只记录一组数据!
其他没细看!
 楼主| 发表于 2013-5-3 19:23 | 显示全部楼层
Gu_xl 发表于 2013-5-3 15:21
错的一塌糊涂!
(while (/= nil)
。。。

有时候不知道具体有多少组数据就让它循环着,不知道怎么跳出。。。。。。
(setq ff (open "d:\\2.csv" "w"))
怪不得最多就一组最后的数据
 楼主| 发表于 2013-5-3 19:35 | 显示全部楼层
(DEFUN C:R1()
  (SETQ P0 (GETPOINT "\n 第一个数据点:"))
  (while (/= (progn
           (setq px (polar (polar p0 0 80) (* 1.5 pi) 22))
           (setq sx (ssget "c" p0 px '((0 . "*text"))))
           )nil)
    (setvar "osmode" 0)
  (setq p1 (polar p0 0 80))
  (setq p2 (polar p1 0 80))
  (setq p3 (polar p2 0 80))
  (setq p4 (polar p3 0 80))
  (setq p5 (polar p4 0 80))
    (setq ss-p (list p0 p1 p2 p3 p4 p5))
  (setq s1 (mapcar '(lambda(x)
               (setq pp (polar (polar x 0 80) (* 1.5 pi) 22))
               (setq s (ssget "c" x pp '((0 . "*text"))))
               (cdr(assoc 1 (entget (ssname s 0)))))
             ss-p
             ))
  (setq s2 (apply '(lambda (x y z x1 y1 z1)
                     (strcat x "," y "," z "," x1 "," y1 "," z1)
                     )
                  s1
                  ))
  (setq ff (open "d:\\2.csv" "a"))
  (write-line s2 ff)
    (close ff)
    (setvar "osmode" 16383)
  (setq p0 (polar p0 (* 1.5 pi) 22))
    )
  )
改了下
发表于 2013-5-4 07:12 来自手机 | 显示全部楼层
选择集循环?while的用法查下资料吧!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-22 06:51 , Processed in 0.222613 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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