0

I need to create the circle from my button click via process dll(Acdbmgd.dll ,acmgd.dll).

I am able to create the circle via COM interop dll. But i don't know how to create the Circle using process dll.

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

But i need to run the code in debug mode so i need to work with exe.Is there anyway to do via exe?

Thanks in advance..

Sivaperuman
  • 239
  • 1
  • 4
  • 21

1 Answers1

1

In process dlls need to be loaded into AutoCAD. Use NetLoad to make the defined commands available to you. 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.

Parrish Husband
  • 3,148
  • 18
  • 40