Run command when .dll is loaded

Run command when .dll is loaded

My_Civil_3D
Advocate Advocate
591 Views
1 Reply
Message 1 of 2

Run command when .dll is loaded

My_Civil_3D
Advocate
Advocate

Hi i am looking for a method to impement a way to check certain autocad variable settings every time the dll is loaded( autocad starts).  Is there a way other than command method to run commands without the user launching them?

Civil 3D Certified Professional
0 Likes
Accepted solutions (1)
592 Views
1 Reply
Reply (1)
Message 2 of 2

Norman_Yuan
Mentor
Mentor
Accepted solution

A class that implement IExtensionApplication would always run the Initialize() method when the DLL is loaded:

 

public class MyPlugin : IExtensionApplication

{

    // this method is called when the DLL is loaded

    public void Initialize()

    {

        // you code here to check the MdiActiveDocument settings

        // you may also handle DocumentCreated event, so that whenever

        // a new drawing or a drawing file is opened, you can also check the 

       // drawing settings

    }

 

    // this method is called when AutoCAD quits

    public void Terminate()

    {

         // in most cases you probably do not need to do anything here

    }

 

   // your other code of the class goes here...

}

 

Make sure you use try...catch to wrap the code in the Initialize(), if the code may result in runtime exception.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes