获取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/> For Each Ent In ThisDrawing.ModelSpace<br/> .Range("A" & i) = i - 1<br/> pt1 = Ent.ObjectID<br/> pt2 = Ent.ObjectName<br/> .Range("B" & i) = Ent.ObjectName<br/> i = i + 1<br/> Next Ent<br/>End With<br/>ExcelApp.ActiveWorkbook.SaveAs "D:\ACADtext.xls"<br/>ExcelApp.Workbooks.Close<br/>ExcelApp.Quit</p><p>End Sub</p> 什么意思? 嗯,要是使用VC++,代码会好长~~
页:
[1]