几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   ObjectARX(AutoLISP) (http://www.dimcax.com/hust/forumdisplay.php?f=178)
-   -   csv导入cad (http://www.dimcax.com/hust/showthread.php?t=10576)

yang686526 2009-04-25 07:51 PM

csv导入cad
 
csv导入cad
www.dimcax.com
csv导入cad
============================================================================
在excel中导出.csv文件,但是不知道.csv文件怎么导入 cad。。
知道的老师请指导一下,谢谢啦!!!!
======================================================================================

要看以什么形式导入到cad了,是属性块,表格,还是文本等等
做过属性块的,比较方便

:
要看以什么形式导入到cad了,是属性块,表格,还是文本等等
做过属性块的,比较方便
我想用文本,能说下比较详细的教程吗?谢谢...

先说一下,我是用vba的,lsp的话那就帮不上忙了
而且我是用属性块的,因为我觉得文本的话,要计算每一行文本的插入点会比较麻烦
平常我也都是用属性块的,附件www.dimcax.com下载次数里有一个我写好的程序,
你看看改一改吧
把插入块改成插入文本,相关程序段我已经标识出来了
改改应该没什么问题的
我看见别人导入cad的图片
上证(1a0001)日线.xls
做出来了,测试过..不过我不太懂楼主要画的是哪个值的线,所以四条都画了,楼主可以删除相应的代码就行了..
把文件解压到任意一个你cad能搜索到的路径就行了.

这是选择csv文件的对话框...楼主你试下看看能达到你的要求不,有什么不对的地方,提出来,我试试修改..程序倒是不麻烦,很简单的几句话..
欢迎大家跟我交流lisp相关问题

=============================================================================


图片:

(defun c:cvs()
(setq #ocm (getvar "cmdecho")) (setvar "osmode" 0)
(setq #oos (getvar "osmode")) (setvar "cmdecho" 0)
(setq #opt1 nil #opt2 nil #opt3 nio #opt4 nil)
(if (setq #csvf (getfiled "请选择csv数据文件" "c:\\" "csv" 2))
(progn
(if (null (tblsearch "block" "csv"))
(command "insert" (strcat "*" "c:\\csv.dwg") "0,0,0" "1" "0")
(command "insert" "csv" "0,0,0" "1" "1" "0")
)
(setq #csvr (open #csvf "r") #tex (read-line #csvr) #tex (read-line #csvr) #xx 0)
(while #tex
(setq #ten (strlen #tex) #tei 1 #lis '() #ate "")
(repeat #ten
(setq #cte (substr #tex #tei 1) #tei (1+ #tei))
(if (/= #cte ",") (setq #ate (strcat #ate #cte)) (setq #lis (cons #ate #lis) #ate "") )
)
(setq #lis (reverse #lis))
(setq #npt1 (list #xx (read (nth 1 #lis))) ) (if (null #opt1) (setq #opt1 #npt1) ) ;;开盘价
(setq #npt2 (list #xx (read (nth 2 #lis))) ) (if (null #opt2) (setq #opt2 #npt2) ) ;;最高价
(setq #npt3 (list #xx (read (nth 3 #lis))) ) (if (null #opt3) (setq #opt3 #npt3) ) ;;最低价
(setq #npt4 (list #xx (read (nth 4 #lis))) ) (if (null #opt4) (setq #opt4 #npt4) ) ;;收盘价
(if (/= #npt1 #opt1) (progn (command "cecolor" "7" "line" #opt1 #npt1 "") (setq #opt1 #npt1) ) ) ;;开盘价
(if (/= #npt2 #opt2) (progn (command "cecolor" "2" "line" #opt2 #npt2 "") (setq #opt2 #npt2) ) ) ;;最高价
(if (/= #npt3 #opt3) (progn (command "cecolor" "3" "line" #opt3 #npt3 "") (setq #opt3 #npt3) ) ) ;;最低价
(if (/= #npt4 #opt4) (progn (command "cecolor" "6" "line" #opt4 #npt4 "") (setq #opt4 #npt4) ) ) ;;收盘价
(setq #tex (read-line #csvr) #xx (1+ #xx))
)
(close #csvr)
)
(princ "\n未选择csv文件,程序退出.")
)
(setvar "osmode" #oos) (setvar "cmdecho" #ocm) (princ)
)
楼主把文件解压到c盘下,再打开csv.lsp文件,把上面的代码覆盖掉原来的,保存好后,在cad命令行输入appload命令,弹出1号对话框,点击"内容"按钮,弹出2号对话框,点"添加",弹出3号对话框,到c盘选中csv.lsp文件,点"添加",再把对话框都关闭掉.输入cvs命令就可以使用了..
欢迎大家跟我交流lisp相关问题


所有的时间均为北京时间。 现在的时间是 04:29 AM.