How to get instantiated plugin class?

nshupeFMPE3
Advocate
Advocate

How to get instantiated plugin class?

nshupeFMPE3
Advocate
Advocate

In the plugin that is generated for learning to write AutoCAD plugins, this is written in the "main" class

 

// This class is instantiated by AutoCAD once and kept alive for the 
    // duration of the session. If you don't do any one time initialization 
    // then you should remove this class.

 

Is it possible to access this instance in order to get at a property that is set up during the Initialize() method? 

0 Likes
Reply
Accepted solutions (1)
376 Views
1 Reply
Reply (1)

_gile
Mentor
Mentor
Accepted solution

Hi,

You can define a static property in the class which implements IExtensionApplication:

 

    public class Initialization : IExtensionApplication
    {
        public static int MeaningOfLife { get; private set; }

        public void Initialize()
        {
            MeaningOfLife = 42;
        }

        public void Terminate()
        { }
    }

 

 

and get its value form other classes with: Initialization.MeaningOfLife



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub