简体   繁体   English

如何在Autocad中使用Visual Studio Exe和Process Dll绘制Circle?

[英]How to draw Circle via visual studio Exe with Process Dll in Autocad?

I need to create the circle from my button click via process dll(Acdbmgd.dll ,acmgd.dll) . 我需要通过process dll(Acdbmgd.dll ,acmgd.dll)从我的按钮单击中创建一个圆圈。

I am able to create the circle via COM interop dll. 我可以通过COM interop dll创建圈子。 But i don't know how to create the Circle using process dll . 但我不知道如何使用process dll创建Circle。

Here is the sample code: 这是示例代码:

        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();
            }

        }

While i execute above code in button click means in runtime error throws like "The specified module could not be found". 当我在按钮单击中执行上述代码时,意味着在运行时抛出错误,例如“找不到指定的模块”。

But if i create one separate dll then i refer that dll in my project and create object for that means it's working 但是,如果我创建一个单独的dll,那么我会在项目中引用该dll并为此创建对象,这意味着它可以正常工作

But i need to run the code in debug mode so i need to work with exe.Is there anyway to do via exe? 但是我需要在调试模式下运行代码,所以我需要使用exe。是否仍然可以通过exe进行操作?

Thanks in advance.. 提前致谢..

In process dlls need to be loaded into AutoCAD. 在处理过程中,需要将dll加载到AutoCAD中。 Use NetLoad to make the defined commands available to you. 使用NetLoad使定义的命令可供您使用。 The command you intend to call needs to be public, and have the following command flag: 您打算调用的命令必须是公共的,并具有以下命令标志:

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

Once you've compiled your dll and loaded it into AutoCAD, typing MyCircle into the command line will invoke your defined method. 编译完dll并将其加载到AutoCAD后,在命令行中键入MyCircle将调用您定义的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM