明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1785|回复: 2

通过csv文件绘图求助

[复制链接]
发表于 2010-11-7 21:01:00 | 显示全部楼层 |阅读模式

具体是这样,csv格式表格中每一行有名称,长度和宽度信息

要求用每一行数据绘制一张DXF格式图,图名称为表格中的名称,图纸内容为以表格中长度和宽度绘制的矩形。

举个例子,如果csv中有5行的话就要有5张DXF格式的图纸。希望是lisp写的,本人是菜鸟,刚接触,哪位大侠能帮助小弟一下,定当感激不尽。

发表于 2010-11-8 14:54:00 | 显示全部楼层
  1. (defun c:tt()
  2.   (defun gxl-StrParse (Str Delimiter / SearchStr StringLen return n char nn)
  3. (setq SearchStr Str)
  4. (setq StringLen (strlen SearchStr) nn StringLen)
  5. (setq return '())
  6. (while (> StringLen 0)
  7.   (setq n 1)
  8.   (setq char (substr SearchStr 1 1))
  9.   (while (and (/= char Delimiter) (<= n nn))
  10.    (setq n (1+ n))
  11.    (setq char (substr SearchStr n 1))
  12.   ) ;_ end of while
  13.   (setq return (cons (substr SearchStr 1 (1- n)) return))
  14.   (setq SearchStr (substr SearchStr (1+ n) StringLen))
  15.   (setq StringLen (strlen SearchStr))
  16. ) ;_ end of while
  17.      (if (= " " Delimiter)
  18.        (setq return (vl-remove  "" return))
  19.        )
  20. (reverse return)
  21. )
  22.   (setq fn (getfiled "请输入文件名 :" "" "csv" 4))
  23.   (setq f (open fn "r"))
  24.   (while (setq zc (read-line f))
  25.     (setq zc (GXL-STRPARSE zc ","))
  26.     (setq fname (car zc)
  27.    L (cadr zc)
  28.    w (caddr zc)
  29.    )
  30.     (command "_.rectang"  '(0 0 0) (strcat "@" l "," w))
  31.     (command "_.dxfout" fname "")
  32.     (command "erase" "all" "")
  33.     )
  34. (close f)
  35.   )
发表于 2010-11-8 22:37:00 | 显示全部楼层
程序要在空白图中运行
游客,本帖隐藏的内容需要发帖数高于 2 才可浏览,你当前发帖数只有 0

您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-27 17:06 , Processed in 0.161649 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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