![]() |
【转帖】如何将cad线段的长度输出到excel中
如何将cad线段的长度输出到excel中
www.dimcax.com 如何将cad线段的长度输出到excel中 我现在有件很无聊的事情要做,就是将cad文件中许多线段的长度写到excel中 然后做其他计算,由于测量的数据太多,手工做会吐血的!! 现在请教各位高手,我应该如何做呢? 我对编程不精通请哪位高手能详细的告诉我~~ 对编程不精通?若想学编程,可以阅读一下名为“vba读写excel文档的一般方法”或“在vc中彻底玩转excel”的帖子。 若只要现成的程序, 请发一个excel样表,编程时需要知道如何填写excel表格。这样的程序用vba相对容易,若需要vlisp或arx程序,请跟帖说明。 最后,这个工作既然对你有用,就不应该是件很无聊的事情。 多谢!我想先解决燃眉之急能否先给出程序?我需要的格式很简单,只需要将cad中的某一层的线长输入到excel中去,excel的格式仅需要序列号和长度,仅仅是长度也可以.公司是为了计算芯片中金线用的. 简单程序 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21sub getlenth() dim excelapp as new excel.application dim excelwkbk as excel.workbook set excelwkbk = excelapp.workbooks.add dim i as integer i = 1 dim ent as acadentity dim pt1 as variant, pt2 as variant with excelwkbk.worksheets("sheet1") for each ent in thisdrawing.modelspace if ent.objectname = "acdbline" then .range("a" & i) = i .range("b" & i) = ent.length i = i + 1 end if next ent end with excelapp.activeworkbook.saveas "d:\acadlen.xls" excelapp.workbooks.close excelapp.quit end sub 程序未加注释。工程需引用microsoft excel object library。excel保存为d:\acadlen.xls。excel文档第一列为序号,第二列为线的长度。 sry,没注意你需要某特定图层对象 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35sub getlenth() dim excelapp as new excel.application dim excelwkbk as excel.workbook set excelwkbk = excelapp.workbooks.add dim i as integer i = 1 dim sel as acadselectionset on error resume next set sel = thisdrawing.selectionsets.add("ss") if err then err.clear thisdrawing.selectionsets.item("ss").delete set sel = thisdrawing.selectionsets.add("ss") end if on error goto 0 dim gpcode(0) as integer dim dbvalue(0) as variant gpcode(0) = 8 dbvalue(0) = "图层1" sel.select acselectionsetall, , , gpcode, dbvalue dim ent as acadentity with excelwkbk.worksheets("sheet1") for each ent in sel if ent.objectname = "acdbline" then .range("a" & i) = i .range("b" & i) = ent.length i = i + 1 end if next ent end with excelapp.activeworkbook.saveas "d:\acadlen.xls" excelapp.workbooks.close excelapp.quit sel.delete end sub 以上程序仅保存“图层1”的线长。 太感谢你了~~~~~ 看来还需多学习! |
所有的时间均为北京时间。 现在的时间是 02:45 AM. |