dl.lzc 发表于 2009-11-18 11:34:00

获取CAD图层中各对象名称

<p>Sub GetObjName()<br/>Dim ExcelApp As New Excel.Application<br/>Dim ExcelWkbk As Excel.Workbook<br/>Set ExcelWkbk = ExcelApp.Workbooks.Add<br/>Dim i As Integer<br/>i = 2<br/>Dim Ent As AcadEntity<br/>Dim pt1 As Variant, pt2 As Variant<br/>With ExcelWkbk.Worksheets("Sheet1")<br/>&nbsp;&nbsp;&nbsp; For Each Ent In ThisDrawing.ModelSpace<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Range("A" &amp; i) = i - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1 = Ent.ObjectID<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt2 = Ent.ObjectName<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Range("B" &amp; i) = Ent.ObjectName<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1<br/>&nbsp;&nbsp;&nbsp; Next Ent<br/>End With<br/>ExcelApp.ActiveWorkbook.SaveAs "D:\ACADtext.xls"<br/>ExcelApp.Workbooks.Close<br/>ExcelApp.Quit</p><p>End Sub</p>

graceandy 发表于 2010-1-5 15:34:00

什么意思?

luowy 发表于 2010-1-26 20:33:00

嗯,要是使用VC++,代码会好长~~
页: [1]
查看完整版本: 获取CAD图层中各对象名称