- UID
- 769956
- 积分
- 36
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2017-7-25
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
正在学习用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
|
|