sunqun0811 发表于 2006-8-31 22:48:00

跪求了!!!!!!!!!!!

急求cad下面的展点连线程序,源码!!!!! 谢谢,小弟真的跪求了!

中世纪骑士 发表于 2006-9-2 20:27:00

你是要读取数据库中的坐标,然后再展点连线么??

中世纪骑士 发表于 2006-9-2 20:39:00

<P>Dim cn As ADODB.Connection<BR>'创建ADO连接并打开<BR>Sub CreateConnection()<BR>&nbsp;&nbsp;&nbsp; Dim ConStr As String&nbsp;&nbsp;&nbsp; '连接字符串<BR>&nbsp;&nbsp;&nbsp; Set cn = New ADODB.Connection<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; cn.CursorLocation = adUseClient<BR>&nbsp;&nbsp;&nbsp; cn.Provider = "Microsoft.Jet.OLEDB.4.0;"<BR>&nbsp;&nbsp;&nbsp; ConStr = "Data Source=你的数据库文件;"<BR>&nbsp;&nbsp;&nbsp; cn.Open ConStr<BR>End Sub</P>
<P><BR>' 从数据库中读取数据<BR>Public Sub ReadFromDB()<BR>&nbsp;&nbsp;&nbsp; ' 创建数据库连接<BR>&nbsp;&nbsp;&nbsp; Call CreateConnection<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 在line表中查询所有的记录<BR>&nbsp;&nbsp;&nbsp; Set rst = New ADODB.Recordset<BR>&nbsp;&nbsp;&nbsp; rst.CursorLocation = adUseClient<BR>&nbsp;&nbsp;&nbsp; rst.Open "SELECT DISTINCT * FROM line", cn, adOpenForwardOnly, _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adLockBatchOptimistic, adCmdText<BR>&nbsp;&nbsp;&nbsp; rst.MoveFirst<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Dim i As Integer<BR>&nbsp;&nbsp;&nbsp; Dim pt1(0 To 2) As Double, pt2(0 To 2) As Double<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 使用查询得到的数据创建直线<BR>&nbsp;&nbsp;&nbsp; For i = 0 To rst.RecordCount - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1(0) = rst.Fields("x1")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1(1) = rst.Fields("y1")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1(2) = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt2(0) = rst.Fields("x2")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt2(1) = rst.Fields("y2")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt2(2) = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.AddLine pt1, pt2<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rst.MoveNext<BR>&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 'rst.Close&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ' 关闭记录集,准备下一次使用<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 在line表中查询<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Set rst = New ADODB.Recordset<BR>&nbsp;&nbsp;&nbsp; rst.CursorLocation = adUseClient<BR>&nbsp;&nbsp;&nbsp; rst.Open "SELECT x1,y1 FROM line", cn, adOpenForwardOnly, _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adLockBatchOptimistic, adCmdText<BR>&nbsp;&nbsp;&nbsp; rst.MoveFirst<BR>&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ' 使用表中的数据绘制圆<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; For i = 0 To rst.RecordCount - 1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1(0) = rst.Fields("x1")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1(1) = rst.Fields("y1")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pt1(2) = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ModelSpace.Addpoint<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rst.MoveNext<BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; Next i<BR>&nbsp;&nbsp;&nbsp; 'rst.Close<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; ThisDrawing.Application.Update<BR>End Sub</P>
<P>这个代码应该符合你的要求</P>
页: [1]
查看完整版本: 跪求了!!!!!!!!!!!