云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > CAD - VBA例子

CAD - VBA例子

  • 62 次阅读
  • 3 次下载
  • 2025/5/1 0:07:35

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 Sub hong()

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

**********************程序源代码***************************

搜索更多关于: CAD - VBA例子 的文档
  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

ThisDrawing.ModelSpace.AddLightWeightPolyline(Pnts) StrLineType = \ LLineColor = 3 MyPln.LineType = StrLineType MyPln.color = LLineColor '宽度设定 MyPln.SetWidth 0, DLineWidth, DLineWidth

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com