一个程序实现CAD里面的一条直线的数据:起点和终点的坐标输出到ACCESS里面! Private Sub CommandButton1_Click() Dim DatabaseObject As Database Dim LineObject As Recordset Dim LObject As AutoCAD.AcadLine Dim Count As Integer Set DatabaseObject = OpenDatabase("D:\数据库\画线.mdb") Set LineObject = DatabaseObject.OpenRecordset("LineData") For Count = 0 To ThisDrawing.ModelSpace.Count - 1 If ThisDrawing.ModelSpace.Item(Count).ObjectName = "AcDbLine" Then LineObject.AddNew Set LObject = ThisDrawing.ModelSpace.Item(Count) LineObject!StartX = LObject.StartPoint(0) LineObject!StartY = LObject.StartPoint(1) LineObject!EndX = LObject.EndPoint(0) LineObject!EndY = LObject.EndPoint(1) LineObject!Color = LObject.Color LineObject.Update Text1.Text = Count End If Next LineObject.Close DatabaseObject.Close Set LineObject = Nothing
MsgBox "Line data sabe to database!" Unload Me End Sub
但是我运行了。确是在ACCESS里面输出了好多行数据。我只是想输出一行。就2个坐标的X和Y的坐标值