多谢版主 在.NET国用类似下面的代码作一个.dll(包含窗体界面的,这部分没有上传),在AutoCAD的命令行中执行AddLine命令, 在AutoCAD中调用时窗体是模态窗口,当需要观察图形结果时而双不想退出程序时不能实现(此时不能调整AutoCAD的窗口)。 所以,当需要根据图形结果再用程序进行结果调整时,用独立于AutoCAD的EXE形式的程序会方便些。 我曾试过在.NET中用AutoCAD ActiveX 控制AutoCAD2007一样好有效,但不知道在一般功能范围内,这种方法与.NET开发接口有什么不同. Imports Autodesk.AutoCAD.Runtime Imports Autodesk.AutoCAD.ApplicationServices Imports Autodesk.AutoCAD.DatabaseServices Imports Autodesk.AutoCAD.Geometry <CommandMethod("AddLine")> _ Public Sub AddLine() Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument Dim acCurDb As Database = acDoc.Database Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction() Dim acBlkTbl As BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) Dim acBlkTblRec As BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), _ OpenMode.ForWrite) Dim acLine As Line = New Line(New Point3d(5, 5, 0), _ New Point3d(12, 3, 0)) acLine.SetDatabaseDefaults() acBlkTblRec.AppendEntity(acLine) acTrans.AddNewlyCreatedDBObject(acLine, True) acTrans.Commit() End Using End Sub |