当前位置:首页 > 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篇相关文档