µ±Ç°Î»ÖãºÊ×Ò³ > CAD - VBAÀý×Ó
ThisDrawing.ModelSpace.AddLightWeightPolyline(Pnts)
StrLineType = \ LLineColor = 3
MyPln.LineType = StrLineType MyPln.color = LLineColor '¿í¶ÈÉ趨
MyPln.SetWidth 0, DLineWidth, DLineWidth
Case \
Pns = ExpObj(J).Coordinates ExpObj(J).Delete
ThisDrawing.ModelSpace.AddPoint (Pns) Case Else
ExpObj(J).Delete 'ÆäËûÈçÎÄ×Ö¡¢µã²»ÔÙ½øÐд¦Àí End Select Next End If
'²»ÊÇ¿éµÄ²»´¦Àí
Next End Sub
16¡¢ÔËÐкê
¡®¡¯¡¯-vbarun
ThisDrawing.Application.RunMacro \End Sub
VBϵÄAutoCAD×Ô¶¯»¯
Ò»¡¢¸ÅÄî
×Ô¶¯»¯¼¼ÊõÔÊÐíÒ»¸öÓ¦ÓóÌÐòÇý¶¯ÁíÍâÒ»¸ö³ÌÐò¡£Çý¶¯³ÌÐò±»³ÆÎª×Ô¶¯»¯¿Í»§£¬ÁíÒ»¸öΪ×Ô¶¯»¯·þÎñÆ÷¡£
VB»·¾³ÏµÄAutoCAD×Ô¶¯»¯¾ÍÊÇÖ¸ÓÃVBÇý¶¯ºÍ²Ù×ÝAutoCAD¡£VBΪ×Ô¶¯»¯¿Í»§
¶Ë£¬AutoCADΪ×Ô¶¯»¯·þÎñÆ÷¡£
³ÌÐò½çÃæ
**********************³ÌÐòÔ´´úÂë***************************
Dim nn As Integer Dim RS As Recordset
Private Sub CommandButton1_Click() Dim I As Integer
Const PDBCN As String = \
Set PCN = New ADODB.Connection Set RS = New ADODB.Recordset
PCN.Open PDBCN + \and Settings\\yb.LH\\×ÀÃæ\\ÒÆ¶¯ÄâºÏ·¨ÄÚ²å\\data1.mdb\
RS.Open \ Set Me.Adodc1.Recordset = RS ' Me.DataGrid1.DataSource = RS nn = RS.RecordCount
If RS.RecordCount > 0 Then MSFlexGrid1.Rows = RS.RecordCount + 1 Else Exit Sub
Me.MSFlexGrid1.ColWidth(0) = 500 Me.MSFlexGrid1.ColAlignment(0) = 3 For I = 1 To 3
Me.MSFlexGrid1.ColWidth(I) = 2500 Me.MSFlexGrid1.ColAlignment(I) = 3 Next
Me.MSFlexGrid1.TextMatrix(0, 0) = \µãºÅ\ Me.MSFlexGrid1.TextMatrix(0, 1) = \ Me.MSFlexGrid1.TextMatrix(0, 2) = \ Me.MSFlexGrid1.TextMatrix(0, 3) = \
RS.MoveFirst I = 0
Do While Not RS.EOF I = I + 1
Me.MSFlexGrid1.TextMatrix(I, 0) = RS.Fields(\ Me.MSFlexGrid1.TextMatrix(I, 1) = RS.Fields(\ Me.MSFlexGrid1.TextMatrix(I, 2) = RS.Fields(\ Me.MSFlexGrid1.TextMatrix(I, 3) = RS.Fields(\ RS.MoveNext Loop ' RS.Close
CommandButton2_Click End Sub
Private Sub CommandButton2_Click() Dim meshObj As AcadPolygonMesh Dim mSize, nSize, count As Integer
'Create the matrix of points ' For I = 0 To nn
mSize = Int(Sqr(nn) - 1): nSize = Int(Sqr(nn) - 1) ReDim points(mSize * nSize * 3 - 1) As Double
If RS.RecordCount > 0 Then RS.MoveFirst For I = 0 To mSize - 1 For J = 0 To nSize - 1
points((I * nSize + J) * 3) = I: points((I * nSize + J) * 3 + 1) = J: points((I * nSize + J) * 3 + 2) = RS.Fields(\ RS.MoveNext Next Next
'creates a 3Dmesh in model space
Set meshObj = ThisDrawing.ModelSpace.Add3DMesh(mSize, nSize, points) 'Change the viewing direction of the viewport to better see the polygonmesh Dim NewDirection(0 To 2) As Double
NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1 ThisDrawing.ActiveViewport.Direction = NewDirection
ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport ZoomAll End Sub
Private Sub CommandButton3_Click()
ThisDrawing.SendCommand Chr(27) + Chr(27) ThisDrawing.SendCommand \ ThisDrawing.Regen acActiveViewport End Sub
Private Sub CommandButton4_Click()
ThisDrawing.SendCommand Chr(27) + Chr(27) ThisDrawing.SendCommand \ ThisDrawing.Regen acActiveViewport End Sub
Private Sub CommandButton5_Click() Unload Me End Sub
**********************³ÌÐòÔ´´úÂë***************************
¹²·ÖÏí92ƪÏà¹ØÎĵµ