明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
12
返回列表 发新帖
楼主: 明经快报

[.net群] 2013-09-05 明经 AutoCAD.NetApi (2474812) 群聊记录:.net 是解释程序,不能加密,只能混淆一下代码!

 关闭 [复制链接]
 楼主| 发表于 2013-9-5 22:12 | 显示全部楼层
毛竹 22:12:47
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

Public Class Form1

    rivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Acadapp As AcadApplication
        Dim Acaddoc As Autodesk.AutoCAD.Interop.AcadDocumentClass
        Dim StartPoint(0 To 2) As Double
        Dim Endpoint(0 To 2) As Double
        StartPoint(0) = 100
        StartPoint(1) = 100
        Endpoint(0) = 200
        Endpoint(1) = 200
        Try
            Acadapp = GetObject(, "AutoCAD.Application.18")
        Catch ex As Exception
            If Err.Number Then
                Err.Clear()
                Acadapp = CreateObject("AutoCAD.Application.18")
                Acadapp = New Autodesk.AutoCAD.Interop.AcadApplicationClass
                Acaddoc = Acadapp.ActiveDocument
                Acadapp.Visible = True
                Acaddoc.ModelSpace.AddLine(StartPoint, EndPoint)
                If Err.Number Then
                    MsgBox(Err.Description)
                    Exit Sub
                End If
            End If
        End Try



    End Sub
End Class
毛竹 22:13:48
以上代码可以autocad2010中正确运行,但是觉得比较奇怪
Acadapplication用 为什么又有AcadapplicationClass
毛竹 22:14:33
不知道有什么区别 请教大家如果知道的话 请指导
毛竹 22:17:40
[qqimg]201309/{74B4EE77-A047-C52B-0D5B-68D853451D58}.jpg[/qqimg]
 楼主| 发表于 2013-9-5 22:34 | 显示全部楼层
毛竹 22:34:24
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.Interop.Common

Public Class Form1

    rivate Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Acadapp As New Autodesk.AutoCAD.Interop.AcadApplicationClass
        Dim Acaddoc As New Autodesk.AutoCAD.Interop.AcadDocumentClass()
        Dim StartPoint(0 To 2) As Double
        Dim Endpoint(0 To 2) As Double
        StartPoint(0) = 100
        StartPoint(1) = 100
        Endpoint(0) = 200
        Endpoint(1) = 200

        Acadapp.Visible = True
        Acaddoc.ModelSpace.AddLine(StartPoint, Endpoint)



    End Sub
End Class
毛竹 22:35:13
原来是这样用的 
Dim Acadapp As New Autodesk.AutoCAD.Interop.AcadApplicationClass 就是相当Createobject("AutoCAD.Application.18")
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-19 05:17 , Processed in 0.172805 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表