菜鸟学习VBA二次开发遇到的弱问题……
最近开始看CAD的二次开发……但是实践的时候遇到一个问题,每次出现ThisDrawing都会出错Name 'ThisDrawing' is not declared.
下面是在网上原样copy的教学程序,可是却在所有的thisdrawing处出错,各位大侠帮忙解决一下吧……many thx……
因为我是菜鸟,可能里面有一些非常弱智的问题……大家见笑了
——————————————
Option Explicit On
Imports AutoCAD
Public Class Form1
Sub Ch2_ConnectToAcad()
Dim acadApp As AcadApplication
On Error Resume Next
acadApp = GetObject(, "AutoCAD.Application")
If Err.Number Then
Err.Clear()
acadApp = CreateObject("AutoCAD.Application")
If Err.Number Then
MsgBox(Err.Description)
Exit Sub
End If
End If
MsgBox("Now running " + acadApp.Name + _
" version " + acadApp.Version)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Arc As AutoCAD.AcadArc
Dim Pnt As Object
Err.Clear()
On Error Resume Next
'选择圆弧
ThisDrawing.Utility.GetEntity(Arc, Pnt, "请选择圆弧:")
If Err.Number <> 13 And Err.Number <> 0 Then Exit Sub
Do Until Arc.ObjectName = "AcDbArc"
Err.Clear()
ThisDrawing.Utility.GetEntity(Arc, Pnt, "你所选的不是圆弧,请重新选择圆弧:")
If Err.Number <> 13 And Err.Number <> 0 Then Exit Sub
Loop
'获取圆弧各属性
Dim Leng As Double
Dim SPnt As Object
Dim EPnt As Object
Dim CPnt As Object
Leng = Arc.ArcLength
SPnt = Arc.StartPoint
EPnt = Arc.EndPoint
CPnt = Arc.Center
'选择标注点
Dim PntforDim As Object
PntforDim = ThisDrawing.Utility.GetPoint(, "选择标注点位置:")
'对圆弧进行角度标注
Dim DimAng As AutoCAD.AcadDim3PointAngular
DimAng = ThisDrawing.ModelSpace.AddDim3PointAngular(CPnt, SPnt, EPnt, PntforDim)
'获取角度标注的精度控制(小数点位)
Dim FormatDot As Integer
Dim FormatTxt As String
FormatDot = DimAng.TextPrecision
'转换为精度控制格式
FormatTxt = "0."
Dim I As Integer
For I = 0 To FormatDot
If I > 0 Then
FormatTxt = FormatTxt & "0"
End If
Next
'更改角度标注的文字内容
DimAng.TextOverride = Format(Leng, FormatTxt)
End Sub
End Class ……没人理我嘛…… 都是英语看不懂:lol :lol :lol :lol :Q :time: :victory: 哈哈 :@ :P 看不懂哦 :(
页:
[1]