关于VB在CAD上画图的问题,求昨天的大神师傅解答~~~
Dim AcadApp As AcadApplicationPrivate Sub Command1_Click()
Dim circleObj As AcadCircle
Dim centerpoint(0 To 2) As Double
Dim radius As Double
centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0
radius = Val(Text1.Text) / 2
Set circleObj = AcadApp.ActiveDocument.ModelSpace.AddCircle(centerpoint, radius)
ZoomAll
centerpoint(0) = 0: centerpoint(1) = 0: centerpoint(2) = 0
radius = Val(Text2.Text) / 2
Set circleObj = AcadApp.ActiveDocument.ModelSpace.AddCircle(centerpoint, radius)
ZoomAll
Dim lineObj As AcadLine
Dim Startpoint(0 To 2) As Double
Dim Endpoint(0 To 2) As Double
Startpoint(0) = 600: Startpoint(1) = 0: Startpoint(2) = 0
Endpoint(0) = 600: Endpoint(1) = Val(Text1.Text) / 2: Endpoint(2) = 0:
Set lineObj = AcadApp.ActiveDocument.ModelSpace.AddLine(Startpoint, Endpoint)
ZoomAll
Startpoint(0) = 600: Startpoint(1) = Val(Text1.Text) / 2: Startpoint(2) = 0
Endpoint(0) = 600 + Val(Text5.Text): Endpoint(1) = Val(Text1.Text) / 2: Endpoint(2) = 0:
Set lineObj = AcadApp.ActiveDocument.ModelSpace.AddLine(Startpoint, Endpoint)
ZoomAll
Startpoint(0) = 600 + Val(Text5.Text): Endpoint(1) = Val(Text1.Text) / 2: Endpoint(2) = 0:
Endpoint(0) = 600 + Val(Text5.Text): Endpoint(1) = -Val(Text1.Text) / 2: Endpoint(2) = 0:
Set lineObj = AcadApp.ActiveDocument.ModelSpace.AddLine(Startpoint, Endpoint)
ZoomAll
Startpoint(0) = 600: Startpoint(1) = 0: Startpoint(2) = 0
Endpoint(0) = 600: Endpoint(1) = -Val(Text1.Text) / 2: Endpoint(2) = 0:
Set lineObj = AcadApp.ActiveDocument.ModelSpace.AddLine(Startpoint, Endpoint)
ZoomAll
Startpoint(0) = 600: Endpoint(1) = -Val(Text1.Text) / 2: Endpoint(2) = 0:
Endpoint(0) = 600 + Val(Text5.Text): Endpoint(1) = -Val(Text1.Text) / 2: Endpoint(2) = 0:
Set lineObj = AcadApp.ActiveDocument.ModelSpace.AddLine(Startpoint, Endpoint)
ZoomAll
End Sub
Private Sub Form_Load()
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set AcadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox ("不能运行AutoCAD 2007,请检查是否安装了AutoCAD 2007")
Exit Sub
End If
End If
AcadApp.Visible = True
End Sub
有点长,请耐心看看