VB程序如何编写成自动输出到CAD图形?方法...
编写程序如画圆,画线其它图形,如何自动生成CAD处理图形文件.也就是说程序的参数改变后,图形也自动生,可以成自动链接状态.可以指导下编个简单例子,只要能输出成CAD图形就...
编写程序如画圆,画线其它图形,如何自动生成CAD处理图形文件.也就是说程序的参数改变后,图形也自动生,可以成自动链接状态.可以指导下编个简单例子,只要能输出成CAD图形就行.
展开
2013-06-30
展开全部
Private Sub Command1_Click()
'首先引用 acad ***Object Library类型库,在工程菜单下面,引用勾选cad
Dim myAcadApp As AutoCAD.AcadApplication, activeDoc As AutoCAD.AcadDocument, acMS As AutoCAD.AcadModelSpace
On Error Resume Next
Set myAcadApp = GetObject(, "Autocad.Application") '检查AutoCAD是否已经打开 Set myAcadApp = CreateObject("Autocad.Application") '打开CAD myAcadApp.Visible = True '显示CAD
If Err <> 0 Then '没有打开
Err.Clear
Set activeDoc = myAcadApp.ActiveDocument
If Err Then
MsgBox Err.Number & ":" & Err.Description '打开失败
Exit Sub
End If
End If
On Error GoTo prcERR
myAcadApp.Visible = True '显示CAD
Set activeDoc = myAcadApp.ActiveDocument
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
Dim LineObj As AcadLine'如果画图时出错,改为Dim LineObj As Object
startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0
endPoint(0) = 30: endPoint(1) = 20: endPoint(2) = 0
Set LineObj = activeDoc.ModelSpace.AddLine(startPoint, endPoint) '画线
prcExit:
Set activeDoc = Nothing
Set myAcadApp = Nothing
Exit Sub
prcERR:
MsgBox Err.Number & ":" & Err.Description, vbCritical, "错误"
Resume prcExit
End Sub
'首先引用 acad ***Object Library类型库,在工程菜单下面,引用勾选cad
Dim myAcadApp As AutoCAD.AcadApplication, activeDoc As AutoCAD.AcadDocument, acMS As AutoCAD.AcadModelSpace
On Error Resume Next
Set myAcadApp = GetObject(, "Autocad.Application") '检查AutoCAD是否已经打开 Set myAcadApp = CreateObject("Autocad.Application") '打开CAD myAcadApp.Visible = True '显示CAD
If Err <> 0 Then '没有打开
Err.Clear
Set activeDoc = myAcadApp.ActiveDocument
If Err Then
MsgBox Err.Number & ":" & Err.Description '打开失败
Exit Sub
End If
End If
On Error GoTo prcERR
myAcadApp.Visible = True '显示CAD
Set activeDoc = myAcadApp.ActiveDocument
Dim startPoint(0 To 2) As Double
Dim endPoint(0 To 2) As Double
Dim LineObj As AcadLine'如果画图时出错,改为Dim LineObj As Object
startPoint(0) = 0: startPoint(1) = 0: startPoint(2) = 0
endPoint(0) = 30: endPoint(1) = 20: endPoint(2) = 0
Set LineObj = activeDoc.ModelSpace.AddLine(startPoint, endPoint) '画线
prcExit:
Set activeDoc = Nothing
Set myAcadApp = Nothing
Exit Sub
prcERR:
MsgBox Err.Number & ":" & Err.Description, vbCritical, "错误"
Resume prcExit
End Sub
2013-06-30
展开全部
做不到!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询