vb和CAD的问题 代码不能在CAD中生成一条直线 求解啊
PrivateSubCommand1_Click()DimacadAppAsAcadApplicationOnErrorResumeNextSetacadApp=GetO...
Private Sub Command1_Click()
Dim acadApp As AcadApplication
On Error
Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err
Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox (" error ")
Exit Sub
End
If
End If
acadApp.Documents.Add
acadApp.Visible = True
acadApp.WindowState =
acMax
Dim lineObj As AcadCircle
Dim P1(0 To 2) As Single
Dim P2(0 To
2) As Single
P1(0) = 500: P1(1) = 500: P1(2) = 0
P2(0) = 0: P2(1) = 0:
P2(2) = 0
Set lineObj = acadApp.ActiveDocument.ModelSpace.AddLine(P1, P2)
End Sub 展开
Dim acadApp As AcadApplication
On Error
Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err
Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox (" error ")
Exit Sub
End
If
End If
acadApp.Documents.Add
acadApp.Visible = True
acadApp.WindowState =
acMax
Dim lineObj As AcadCircle
Dim P1(0 To 2) As Single
Dim P2(0 To
2) As Single
P1(0) = 500: P1(1) = 500: P1(2) = 0
P2(0) = 0: P2(1) = 0:
P2(2) = 0
Set lineObj = acadApp.ActiveDocument.ModelSpace.AddLine(P1, P2)
End Sub 展开
2个回答
展开全部
Private Sub Command1_Click()
Dim AcadApp As Object '采用后期绑定,可以适用不同的CAD版本
Dim AcadDoc As Object
Dim MoSpace As Object
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set AcadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox "没有安装CAD软件"
Exit Sub
End If
End If
Set AcadDoc = AcadApp.ActiveDocument
Set MoSpace = AcadDoc.modelspace
AcadApp.Visible = True
Dim lineObj As Object
Dim P1(0 To 2) As Double
Dim P2(0 To 2) As Double
P1(0) = 500: P1(1) = 500: P1(2) = 0
P2(0) = 0: P2(1) = 0: P2(2) = 0
Set lineObj = MoSpace.AddLine(P1, P2)
Set MoSpace = Nothing '释放对象
Set AcadDoc = Nothing
Set AcadApp = Nothing
End Sub
Dim AcadApp As Object '采用后期绑定,可以适用不同的CAD版本
Dim AcadDoc As Object
Dim MoSpace As Object
On Error Resume Next
Set AcadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set AcadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox "没有安装CAD软件"
Exit Sub
End If
End If
Set AcadDoc = AcadApp.ActiveDocument
Set MoSpace = AcadDoc.modelspace
AcadApp.Visible = True
Dim lineObj As Object
Dim P1(0 To 2) As Double
Dim P2(0 To 2) As Double
P1(0) = 500: P1(1) = 500: P1(2) = 0
P2(0) = 0: P2(1) = 0: P2(2) = 0
Set lineObj = MoSpace.AddLine(P1, P2)
Set MoSpace = Nothing '释放对象
Set AcadDoc = Nothing
Set AcadApp = Nothing
End Sub
天正软件
2024-08-02 广告
2024-08-02 广告
天正软件可以解决以下问题:1. 提供设计标准化:天正软件专注于勘察设计领域,为用户提供标准化、信息化、智能化的解决方案,以提高设计效率、优化设计流程、降低成本。2. 提高绘图效率:天正软件提供了一系列专业绘图工具,能够帮助设计师快速绘制图纸...
点击进入详情页
本回答由天正软件提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询