vb中画CAD
比如说建立一个VB的formPrivateSubCommand1_Click()dddsinlEndSubSubddd()DimmyAcadAppAsAutoCAD.Ac...
比如说 建立一个VB的 form
Private Sub Command1_Click()
ddd
sinl
End Sub
Sub ddd()
Dim myAcadApp As AutoCAD.AcadApplication
On Error Resume Next
Set myAcadApp = GetObject(, "Autocad.Application") '检查AutoCAD是否已经打开
If Err.Number <> 0 Then '没有打开
Set myAcadApp = CreateObject("Autocad.Application") '打开CAD
End If
On Error GoTo 0
myAcadApp.Visible = True '显示CAD
End Sub
Sub sinl()
Dim p(0 To 719) As Double '定义点坐标
For i = 0 To 718 Step 2 '开始画多段线
p(i) = i * 2 * 3.1415926535897 / 360 '横坐标
p(i + 1) = 2 * Sin(p(i)) '纵坐标
Next i
ThisDrawing.ModelSpace.AddLightWeightPolyline (p) '画多段线
ZoomExtents '显示整个图形
End Sub
我想问个事,为什么这个程序可以把CAD打开,但却无法在CAD中绘制sin曲线,求高手帮忙~
不是 VBA , 使用vb来实现 调用CAD,同时在CAD中画图 展开
Private Sub Command1_Click()
ddd
sinl
End Sub
Sub ddd()
Dim myAcadApp As AutoCAD.AcadApplication
On Error Resume Next
Set myAcadApp = GetObject(, "Autocad.Application") '检查AutoCAD是否已经打开
If Err.Number <> 0 Then '没有打开
Set myAcadApp = CreateObject("Autocad.Application") '打开CAD
End If
On Error GoTo 0
myAcadApp.Visible = True '显示CAD
End Sub
Sub sinl()
Dim p(0 To 719) As Double '定义点坐标
For i = 0 To 718 Step 2 '开始画多段线
p(i) = i * 2 * 3.1415926535897 / 360 '横坐标
p(i + 1) = 2 * Sin(p(i)) '纵坐标
Next i
ThisDrawing.ModelSpace.AddLightWeightPolyline (p) '画多段线
ZoomExtents '显示整个图形
End Sub
我想问个事,为什么这个程序可以把CAD打开,但却无法在CAD中绘制sin曲线,求高手帮忙~
不是 VBA , 使用vb来实现 调用CAD,同时在CAD中画图 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询