zjyingxf 发表于 2009-11-18 10:53:00

怎么用VBA获得圆的圆心座标呢

各位大侠,怎么用VBA获得圆的圆心座标呢,急需。先谢谢了

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

<p>Sub GetCenter()<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; If Ent.ObjectName = "AcDbCircle" Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Range("A" &amp; i) = i - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1 = Ent.Center<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Range("B" &amp; i) = pt1(0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Range("C" &amp; i) = pt1(1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; i = i + 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br/>&nbsp;&nbsp;&nbsp; Next Ent<br/>End With<br/>ExcelApp.ActiveWorkbook.SaveAs "D:\AcDCenter.xls"<br/>ExcelApp.Workbooks.Close<br/>ExcelApp.Quit</p><p>End Sub<br/>结果在"D:\AcDCenter.xls"里</p>

monkeylzx 发表于 2011-4-2 13:08:29

新手来学习了,多谢分享。
页: [1]
查看完整版本: 怎么用VBA获得圆的圆心座标呢