如何在Autocad中使用Process Dll通过Visual Studio Exe绘制Circle

本文关键字:Visual 通过 Studio Exe Circle 绘制 Dll Process Autocad | 更新日期: 2023-09-27 18:33:36

我需要通过process dll(Acdbmgd.dll ,acmgd.dll)单击按钮创建圆圈。

我能够通过COM互操作dll创建圆圈。但是我不知道如何使用process dll创建圆圈。

下面是示例代码:

        Database db = HostApplicationServices.WorkingDatabase;
        Document doc = Autodesk.AutoCAD.ApplicationServices.
                Application.DocumentManager.GetDocument(db);
        // Perform our addition
        double res = 5 + 9;
        // Lock the document before we access it
        DocumentLock loc = doc.LockDocument();
        using (loc)
        {
            Transaction tr = db.TransactionManager.StartTransaction();
            using (tr)
            {
                // Create our circle
                Circle cir = 
           new Circle(new Point3d(0, 0, 0), new Vector3d(0, 0, 1), res);
                cir.SetDatabaseDefaults(db);
                // Add it to the current space
                BlockTableRecord btr = (BlockTableRecord)tr
              .GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
                btr.AppendEntity(cir);
                tr.AddNewlyCreatedDBObject(cir, true);
                // Commit the transaction
                tr.Commit();
            }
        }

当我在按钮单击中执行上述代码时,意味着运行时会抛出诸如"找不到指定的模块"之类的错误。

但是,如果我创建一个单独的 dll,那么我会在我的项目中引用该 dll 并为此创建对象,这意味着它正在工作

但是我需要在调试模式下运行代码,所以我需要使用 exe。无论如何可以通过exe做什么吗?

提前谢谢..

如何在Autocad中使用Process Dll通过Visual Studio Exe绘制Circle

进程中的 dll 需要加载到 AutoCAD 中。 使用 NetLoad 使定义的命令可供您使用。要调用的命令必须是公共的,并具有以下命令标志:

[CommandMethod("MyCircle")]
public static void MyCircle()
{
    ...
}

编译 dll 并将其加载到 AutoCAD 后,在命令行中键入 MyCircle 将调用您定义的方法。

相关文章: