找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 536|回复: 0

[求助] 请高手帮忙看一下,开发autocad插件为什么在autocad中没有...

[复制链接]
发表于 2021-4-15 16:06:49 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
正在学习用VB2010写autocad2010的插件,以下代码中除
   <CommandMethod("AddLine")> _
        Public Sub AddLine()
这个过程是从事例中复制得来外,其余均为电脑自动生成代码。
我编译生成dll后,在autocad中用netload加载了这个dll后,健入“AddLine”命令,但提示没有这个命令,这是怎么回事?


' (C) Copyright 2021 by Microsoft
'
Imports System
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.EditorInput
<Assembly: ExtensionApplication(GetType(AutoCAD_VB_plug_in1.MyPlugin))>

Namespace AutoCAD_VB_plug_in1
    Public Class MyPlugin
        Implements IExtensionApplication

        Public Sub Initialize() Implements IExtensionApplication.Initialize
        End Sub

        <CommandMethod("AddLine")> _
        Public Sub AddLine()
            '' 获得当前文档和数据库   Get the current document and database
            Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim acCurDb As Database = acDoc.Database

            ''启动一个事务   Start a transaction
            Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()

                '' 以只读方式打开块表   Open the Block table for read
                Dim acBlkTbl As BlockTable
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)

                '' 以写方式打开模型空间块表记录   Open the Block table record Model space for write
                Dim acBlkTblRec As BlockTableRecord
                acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _
                                                OpenMode.ForWrite)

                '' 创建一条起点为(5,5,0),终点为(12,3,0)的直线  Create a line that starts at 5,5 and ends at 12,3
                Dim acLine As Line = New Line(New Point3d(5, 5, 0), _
                                              New Point3d(12, 3, 0))
                acLine.SetDatabaseDefaults()

                '' 添加新对象到块表记录和事务中   Add the new object to the block table record and the transaction
                acBlkTblRec.AppendEntity(acLine)
                acTrans.AddNewlyCreatedDBObject(acLine, True)

                '' 保存新对象到数据库中   Save the new object to the database
                acTrans.Commit()
            End Using
        End Sub

        Public Sub Terminate() Implements IExtensionApplication.Terminate
            ' Do plug-in application clean up here
        End Sub
    End Class

End Namespace
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-28 06:19 , Processed in 0.353469 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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